Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. XmlTextReader - Child elements.

XmlTextReader - Child elements.

Scheduled Pinned Locked Moved .NET (Core and Framework)
xmlhelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    coleydog
    wrote on last edited by
    #1

    Hi All, I am reading Xml data using XmlTextReader on a file stream. I read the elements and the element attributes with no problem but I can't figure out how to identify if the current element has further child elements or is finalized (ends with />). I can handle (the reader.Read() shows 'Element' (with 2 attributes) then EndElement - no problem) I have problems with ; (the reader.Read() shows 'Element' (with 2 attributes) then the next element) In the second case I can't figure out if the next element is a child element or not. Or to be more precise I don't know when the original element ends. Thanks.

    D 1 Reply Last reply
    0
    • C coleydog

      Hi All, I am reading Xml data using XmlTextReader on a file stream. I read the elements and the element attributes with no problem but I can't figure out how to identify if the current element has further child elements or is finalized (ends with />). I can handle (the reader.Read() shows 'Element' (with 2 attributes) then EndElement - no problem) I have problems with ; (the reader.Read() shows 'Element' (with 2 attributes) then the next element) In the second case I can't figure out if the next element is a child element or not. Or to be more precise I don't know when the original element ends. Thanks.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Why not just load the entire document into an XmlDocument instead?? Then you can get all the child element collection information you want?

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      C 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Why not just load the entire document into an XmlDocument instead?? Then you can get all the child element collection information you want?

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        C Offline
        C Offline
        coleydog
        wrote on last edited by
        #3

        Thanks for that. That's what I've now done. Works fine. I just thought there would have to be some sort of 'HasEndElement' type property for an Element node on the XmlTextReader.Read Element. Cheers. :)

        D 1 Reply Last reply
        0
        • C coleydog

          Thanks for that. That's what I've now done. Works fine. I just thought there would have to be some sort of 'HasEndElement' type property for an Element node on the XmlTextReader.Read Element. Cheers. :)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Since the Reader hasn't gotten that far, there's no way for it to tell...

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups