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. XML / XSL
  4. How to get the exact node info - XML parsing question

How to get the exact node info - XML parsing question

Scheduled Pinned Locked Moved XML / XSL
helpxmljsontutorialquestion
2 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.
  • J Offline
    J Offline
    Joe_P
    wrote on last edited by
    #1

    Hi My xml looks like this and I have pasted the code below to parse. The issue is : The first two table nodes have just the LocnId info. So when I fetch LocnId and Zip code, the result of parsing is like this LocnId Zip 1 30339 2 20000 8 undefined 9 undefinde Expected output is LocnId Zip 1 null 2 null 8 30339 9 20000 1

    2

    830339

    920000

    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.load("data.xml"); var x = xmlDoc.getElementsByTagName('Table'); for (var i = 0; i < x.length; i++) { LocnId = xmlDoc.getElementsByTagName("LocnId")[i].childNodes[0].nodeValue; Zip = xmlDoc.getElementsByTagName("Zip")[i].childNodes[0].nodeValue; } I am trying to figureout other methods to fetch the node values, but havent figured out yet, any links/help is greatly appreciated. Thanks Joe

    N 1 Reply Last reply
    0
    • J Joe_P

      Hi My xml looks like this and I have pasted the code below to parse. The issue is : The first two table nodes have just the LocnId info. So when I fetch LocnId and Zip code, the result of parsing is like this LocnId Zip 1 30339 2 20000 8 undefined 9 undefinde Expected output is LocnId Zip 1 null 2 null 8 30339 9 20000 1

      2

      830339

      920000

      var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.load("data.xml"); var x = xmlDoc.getElementsByTagName('Table'); for (var i = 0; i < x.length; i++) { LocnId = xmlDoc.getElementsByTagName("LocnId")[i].childNodes[0].nodeValue; Zip = xmlDoc.getElementsByTagName("Zip")[i].childNodes[0].nodeValue; } I am trying to figureout other methods to fetch the node values, but havent figured out yet, any links/help is greatly appreciated. Thanks Joe

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      You can try XPath[^], which is easy and efficient.

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

      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