create XML file from string containing XML

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

Is it possible to convert a string to XML? I have an XML document
coming in to my web page through Request.QueryString"xml" as a string.
I need to create a new XML file made up of the XML in this string. Can
anybody help me out?

Cheers,

lfc77
 
Sure, create an XmlDocument object:

XmlDocument xmldoc = new XmlDocument();

Then call the LoadXml method to parse in a string...

xmldoc.LoadXml(szXmlString);


You put XML file though? What do you mean by file? The above loads the XML
string into the XML Dom object, but that's only in the memory... If you want
to stream it to a file, then what you do is this...

StreamWriter wrtr = File.CreateText( "<<myfilename.xml>>" );
wrtr.Write( szXmlString );
wrtr.Flush();
wrtr.Close();


anymore questions, lemme know.
Dan.


Is it possible to convert a string to XML? I have an XML document
coming in to my web page through Request.QueryString"xml" as a string.
I need to create a new XML file made up of the XML in this string. Can
anybody help me out?

Cheers,

lfc77
 
Back
Top