I am writing a code to get an XML file as follows.
---------------------------------------------------------------------
-----------------------------------------------------------------------------------------
I am using the following code.
----------------------------------------------------------------------------------------
XmlTextWriter textWriter = new XmlTextWriter("C:\\temp\\AMXmlFile.xml", Encoding.UTF8);
textWriter.Formatting = Formatting.Indented;
textWriter.Indentation = 4;
textWriter.WriteStartDocument();
textWriter.WriteStartElement("channel", "");
textWriter.WriteStartElement("item", "");
textWriter.WriteStartElement("title", "");
textWriter.WriteString("Mark");
textWriter.WriteEndElement();
textWriter.WriteEndElement();
textWriter.WriteStartElement("desription", "");
textWriter.WriteString("4352,plano rd.");
textWriter.WriteEndElement();
textWriter.WriteStartElement("geo\":\"lat","");
textWriter.WriteString("43.646870");
textWriter.WriteEndElement();
// Ends the document.
textWriter.WriteEndElement();
textWriter.WriteEndDocument();
// close writer
textWriter.Flush();
textWriter.Close();
---------------------------------------------------------------------------
I am getting an error in the line
textWriter.WriteStartElement("geo\":\"lat","");
What do I need to write in my code to have the following line in my XML file.
I have tried the following also, but it didn't work.
xmlWriter.WriteStartElement("geo:lat");
xmlWriter.WriteString("43.646870");
xmlWriter.WriteEndElement();
Also I am not able to get the line
What I need to write to get the solution of my above problems. I will appreciate your help.
Thanks.
vivek kulkarniPosted May 30, 2009, 3:13 AM
Here is the Naming rules as per the xml specifications.
The first character of a Name MUST be a NameStartChar, and any other characters MUST be NameChars; this mechanism is used to prevent names from beginning with European (ASCII) digits or with basic combining characters. Almost all characters are permitted in names, except those which either are or reasonably could be used as delimiters. The intention is to be inclusive rather than exclusive, so that writing systems not yet encoded in Unicode can be used in XML names. See J Suggestions for XML Names for suggestions on the creation of names.
Document authors are encouraged to use names which are meaningful words or combinations of words in natural languages, and to avoid symbolic or white space characters in names. Note that COLON, HYPHEN-MINUS, FULL STOP (period), LOW LINE (underscore), and MIDDLE DOT are explicitly permitted.
The ASCII symbols and punctuation marks, along with a fairly large group of Unicode symbol characters, are excluded from names because they are more useful as delimiters in contexts where XML names are used outside XML documents; providing this group gives those contexts hard guarantees about what cannot be part of an XML name. The character #x037E, GREEK QUESTION MARK, is excluded because when normalized it becomes a semicolon, which could change the meaning of entity references.
Names and Tokens
NameStartChar":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]NameCharNameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]NameNameStartChar (NameChar)*NamesName (#x20 Name)*Nmtoken(NameChar)+NmtokensNmtoken (#x20 Nmtoken)*Thank you,