Results 1 to 2 of 2

Thread: [RESOLVED] Finding distinct attributes from a xml node

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2006
    Posts
    8

    Resolved [RESOLVED] Finding distinct attributes from a xml node

    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 structure
    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>
    I only need unique "type" values. In the example on the link above it uses the following xpath:
    Code:
           Set xmlNodesColl = objXMLDoc.selectNodes( _
                "/contacts/contact[not(@type = preceding-sibling::contact/@type)]/@type")
    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.
    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.
    Last edited by Hack; May 24th, 2006 at 12:11 PM. Reason: Added [code] [/code] tags for more clarity.

  2. #2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width