Need to know if it is possible to check whether an attribute exists? As you can see below, the same XML file will be used by multiple users. I want to check to see if the attribute "name" exists. If not -I will create. If so, I pull the value.
Before "Set nodSelect" statement, I would like to check to see if the name="tom" exists...possible?
XML:
<program>
<user name="steve">
<org>Lawn Movers</org>
<site>Los Angeles</site>
<pos>Gardner</pos>
<msi>20080204A</msi>
<updates>20080409</updates>
</user>
<user name="tom">
<org>Lawn Movers</org>
<site>Los Angeles</site>
<pos>Gardner</pos>
<msi>20080204A</msi>
<updates>20080409</updates>
</user>
</Program>
Parsing with:
Function readXML(byVal strValue, byValue sUser)
strXpath = "/program/user[@name='" & sUser & "']"
Set nodSelect = oXML.selectSingleNode(strXpath).childNodes
For Each x In nodSelect
If x.nodeName = strValue Then
readXML = x.text
End If
Next
End Function
Before "Set nodSelect" statement, I would like to check to see if the name="tom" exists...possible?
XML:
<program>
<user name="steve">
<org>Lawn Movers</org>
<site>Los Angeles</site>
<pos>Gardner</pos>
<msi>20080204A</msi>
<updates>20080409</updates>
</user>
<user name="tom">
<org>Lawn Movers</org>
<site>Los Angeles</site>
<pos>Gardner</pos>
<msi>20080204A</msi>
<updates>20080409</updates>
</user>
</Program>
Parsing with:
Function readXML(byVal strValue, byValue sUser)
strXpath = "/program/user[@name='" & sUser & "']"
Set nodSelect = oXML.selectSingleNode(strXpath).childNodes
For Each x In nodSelect
If x.nodeName = strValue Then
readXML = x.text
End If
Next
End Function