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. C#
  4. XMLTextReader - Find Max Depth

XMLTextReader - Find Max Depth

Scheduled Pinned Locked Moved C#
question
3 Posts 3 Posters 2 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.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    XMLTextReader has a depth property that returns the depth of the current node. Anyone know a way to determine the maximum depth? I guess I could read through the file first, but that doesn't seem very efficient.

    Everything makes sense in someone's mind

    H B 2 Replies Last reply
    0
    • K Kevin Marois

      XMLTextReader has a depth property that returns the depth of the current node. Anyone know a way to determine the maximum depth? I guess I could read through the file first, but that doesn't seem very efficient.

      Everything makes sense in someone's mind

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Until you read through the file, the XML reader wouldn't know anyway (even if, as another example, you used an XPathNavigator to search only leaf nodes). But a better question is why you need to find depth? Because to do so may be considered inefficient, maybe first you should determine if you really need to.

      This posting is provided "AS IS" with no warranties, and confers no rights. Program Manager Visual Studio Professional Deployment Experience Microsoft [My Articles] [My Blog] [Follow on Twitter]

      1 Reply Last reply
      0
      • K Kevin Marois

        XMLTextReader has a depth property that returns the depth of the current node. Anyone know a way to determine the maximum depth? I guess I could read through the file first, but that doesn't seem very efficient.

        Everything makes sense in someone's mind

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        XML doesn't include structure metadata in a header or anything, so to find the maximum depth you would have to read the whole document and check every node.

        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