Accessing attributes without knowing there names
-
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. -
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.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
-
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.You can access this by using dataset ds.ReadXml(XML FILE path); j=0; while(j