Hi Everyone,
I was referring to one of the examples which I found on internet to find how we can use preceding-sibling to find distinct values from an xml using Visual Basic. I am using MS XML 3.0 in my project. http://www.perfectxml.com/msxmlAnswers.asp?Row_ID=101. I will explain it here too.
For eg: this is my xml structureI only need unique "type" values. In the example on the link above it uses the following xpath:Code:<?xml version="1.0" encoding="UTF-8"?> <contacts> <contact type="friend"> <name>Joe</name> </contact> <contact type="friend"> <name>Rick</name> </contact> <contact type="foe"> <name>Bob</name> </contact> <contact type="friend"> <name>Jeff</name> </contact> <contact type="friend"> <name>Mark</name> </contact> </contacts>When I try using it, I always get an error message to replace token : with ) and so on. I am not sure where I am going wrong.Code:Set xmlNodesColl = objXMLDoc.selectNodes( _ "/contacts/contact[not(@type = preceding-sibling::contact/@type)]/@type")
Can someone please suggest what is the problem with the above code or if there is an alternative solution? The above problem could also be because I am using MS XML 3 and in the example on the link above it asks to use MS XML 4. Please suggest.
Thanks for your help.




Reply With Quote