XML writing

May 30 2009 1:28 AM

Hi,

I am writing a code to get an XML file as follows.
---------------------------------------------------------------------
<?xml version="1.0" ?>
<channel>
<item>
<title>Mark</title>
<description>2001,Denton Rd., Lewisville, TX</description>
</item>
<geo:lat>43.646870</geo:lat>
<geo:long>-79.383342</geo:long>

-----------------------------------------------------------------------------------------
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.
<geo:lat>43.646870</geo:lat>

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 <rss version="0.92" xml:base="http://www.primaryobjects.com">.
What I need to write to get the solution of my above problems. I will appreciate your help.
Thanks.
 


 

Answers (1)