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. Accessing attributes without knowing there names

Accessing attributes without knowing there names

Scheduled Pinned Locked Moved XML / XSL
htmlxmlquestion
3 Posts 3 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.
  • S Offline
    S Offline
    sweep123
    wrote on last edited by
    #1

    When using DOM to process an XML file, I need to get hold of the attributes when present. Now I can get hold of them if I know there names, but what about when I do not know the attribute names? Set objAttributes = objDOMNode.Attributes 'check that there are attributes. If objAttributes.length > 0 Then 'we know that we've named our id reference as ''PERSONID', therefore tell the NameNodeListMap to get 'this node by using the getNamedItem method Set objAttributeNode = objAttributes.getNamedItem("PERSONID") 'store this value in the tag of the treeview tvwElement.Tag = objAttributeNode.nodeValue End If The above code is OK for when you know the attribute name, but its the case when you dont know the number and names. Any suggests please.

    E M 2 Replies Last reply
    0
    • S sweep123

      When using DOM to process an XML file, I need to get hold of the attributes when present. Now I can get hold of them if I know there names, but what about when I do not know the attribute names? Set objAttributes = objDOMNode.Attributes 'check that there are attributes. If objAttributes.length > 0 Then 'we know that we've named our id reference as ''PERSONID', therefore tell the NameNodeListMap to get 'this node by using the getNamedItem method Set objAttributeNode = objAttributes.getNamedItem("PERSONID") 'store this value in the tag of the treeview tvwElement.Tag = objAttributeNode.nodeValue End If The above code is OK for when you know the attribute name, but its the case when you dont know the number and names. Any suggests please.

      E Offline
      E Offline
      Elina Blank
      wrote on last edited by
      #2

      You need to loop through all elements checking what attributes they have and where. Check this for XPath expressions: [^]. Look for "Selecting Unknown Nodes" Sincerely, Elina Life is great!!! Enjoy every moment of it! :-O

      1 Reply Last reply
      0
      • S sweep123

        When using DOM to process an XML file, I need to get hold of the attributes when present. Now I can get hold of them if I know there names, but what about when I do not know the attribute names? Set objAttributes = objDOMNode.Attributes 'check that there are attributes. If objAttributes.length > 0 Then 'we know that we've named our id reference as ''PERSONID', therefore tell the NameNodeListMap to get 'this node by using the getNamedItem method Set objAttributeNode = objAttributes.getNamedItem("PERSONID") 'store this value in the tag of the treeview tvwElement.Tag = objAttributeNode.nodeValue End If The above code is OK for when you know the attribute name, but its the case when you dont know the number and names. Any suggests please.

        M Offline
        M Offline
        MODI_RAHUL
        wrote on last edited by
        #3

        You can access this by using dataset ds.ReadXml(XML FILE path); j=0; while(j

        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