How to create XmlTextReader object for a string stored XML content Many Thanks!
Normally, we create XmlTextReader object using a filename parameter, such as XmlTextReader my = new XmlTextReader(@"E:\Temp_WriteXMLToBookmark\1.xml");
but I have stored XML content into a string, how to create XmlTextReader object for the string stored XML content
There is a stupid way, that is to save the string as a XML file first,then use XmlTextReader my = new XmlTextReader(@"E:\Temp_WriteXMLToBookmark\1.xml");
Could you give a good idea

How to create XmlTextReader object for a string stored XML content? Many Thanks!
Arvan
You can then pass the stream to the constructor for XmlTextReader. This requires that the string be duplicated so if it is large then this would be inefficient. Instead you should probably create a special stream called StringStream that reads directly from the source string. Steven Toub in the .NET Matters column of MSDN Magazine, July 2005 did exactly this when someone asked him the same question. Goto http://msdn.microsoft.com/msdnmag/issues/05/07/NETMatters/ to get the StringStream implementation. That is where I got the above code by the way.
Michael Taylor - 10/28/05
Guglielmo
For what it is worth this what I did using framework 2.0:
String
strXML = "<root><tag>data</tag></root>"; XmlTextReader reader = new XmlTextReader(new StringReader(strXML));Kristin
I stumbled upon another method for doing this mentioned in the MS help:
string xmlFrag ="<item rk:ID='abc-23'>hammer</item> " + "<item rk:ID='r2-435'>paint</item>" + "<item rk:ID='abc-39'>saw</item>"; // Create the XmlNamespaceManager. NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace("rk", "urn:store-items"); // Create the XmlParserContext. XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); // Create the reader. XmlReaderSettings settings = new XmlReaderSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; XmlReader reader = XmlReader.Create(new StringReader(xmlFrag), settings, context); Hope this helps.noobProgrammer