Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done
Generic  xmlTextReader
 
Original article:
 
 
                    ////------------------------------------------------------------------
                    ////convert XML string to MemoryStream
                    ////------------------------------------------------------------------
                    MemoryStream memoryStream = new MemoryStream();
                    byte[] data = Encoding.Unicode.GetBytes(strippedXml);
                    memoryStream.Write(data, 0, data.Length);
                    memoryStream.Position = 0;
 
                    ////------------------------------------------------------------------
                    ////convert MemoryStream to xmlTextReader
                    ////------------------------------------------------------------------
                    //XmlTextReader xmlTextReader = new XmlTextReader(Server.MapPath("test.xml"));
                    XmlTextReader xmlTextReader = new XmlTextReader(memoryStream);
 
                    ////------------------------------------------------------------------
                    ////
                    ////------------------------------------------------------------------
                    while (xmlTextReader.Read())
                    {
                        switch (xmlTextReader.NodeType)
                        {
                            case XmlNodeType.Element:
                                Debug.WriteLine(xmlTextReader.Name.ToString());
                                break;
                            case XmlNodeType.Text:
                                Debug.WriteLine(xmlTextReader.Value.ToString());
                                break;
                            case XmlNodeType.EndElement:
                                Debug.WriteLine(xmlTextReader.Name.ToString());
                                break;
                        }
                    }
Posted on Wednesday, August 13, 2008 2:26 AM XML & Datasets | Back to top


Comments on this post: Generic xmlTextReader

# re: Generic xmlTextReader
Requesting Gravatar...
Very helpful post, thank you!
Left by canvas prints on Dec 07, 2011 5:02 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net