CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Read Nested XML

  1. #1
    Join Date
    May 2012
    Posts
    9

    Question Read Nested XML

    Ok... here is my problem...

    I want to read what is inside of a tag even if it is another tag... but I just cannot seem to figure it out!

    My XML is :

    <doc>
    <page><title>Hi</title></page>
    </doc>

    How do I get what is inside the page tag? (the return should be "title>Hi</title>") but so far I cannot get that!

    Right now I'm using the XmlTextReader to read the file and then switch the NodeTypes to find the Elements/Text/EndElements...

    But Elements returns the Elements, and the Text return what is inside the inner most Element! NOT the particular element.

    I think the problem is that it reads the XML line by line rather than whole and then process...

    Any help is appreciated.

  2. #2
    Join Date
    Jan 2007
    Posts
    491

    Re: Read Nested XML

    1. Find the XmlNode corresponding to <page> (i.e., by accessing the first child of the root node)
    2. Print the InnerXml / OuterXml properties of this node: http://msdn.microsoft.com/en-us/libr....innerxml.aspx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured