Solved

Classic ASP XPath select parent node where child node has certain text

Posted on 2009-07-02
5
1,923 Views
Last Modified: 2013-11-11
In Classic ASP I have an XML document loaded into a session variable session("ArrayOfInformation")
I have available to me the PartnerUid.
I need to find out:
1- Is there a node in the XML where the PartnerUid is what I am looking for
2- If there is such a node, I need the DsiplayName and the DirectoryName

If someone can point me to the appropriate XPATH so that I can run selectSingleNode on the "Information" node that contains the child node I am looking for, I can get to the two values I am looking for.

<ArrayOfInformation>
  <Information>
    <PartnerId>12345</PartnerId>
    <Description>Description Here</Description>
    <DirectoryName>Directory Name Here</DirectoryName>
    <PartnerUid>54321</PartnerUid>
    <DisplayName>Display Name Here</DisplayName>
  </Information>
  <Information>
    <PartnerId>67890</PartnerId>
    <Description>Description Here</Description>
    <DirectoryName>Directory Name Here</DirectoryName>
    <PartnerUid>098765</PartnerUid>
    <DisplayName>Display Name Here</DisplayName>
  </Information>
</ArrayOfInformation>

Open in new window

0
Comment
Question by:nap0leon
  • 3
5 Comments
 
LVL 27

Accepted Solution

by:
BigRat earned 500 total points
ID: 24771094
infoNode = xmldoc.selectSingleNode('/ArrayOfInformation/Information[PartnerId="1234"]');

If infoNode is nothing, then not found. Otherwise you've got the info node.

Note you can make up the selection string yourself, dynamically, but please not the usage of different quotes!

The other two data are :-

     infoNode.selectSingleNode('DisplayName').text;

and

   infoNode.selectSingleNode('DirectoryName').text;

0
 
LVL 18

Author Comment

by:nap0leon
ID: 24796535
I went the XPATH route

objXML.selectSingleNode("//ArrayOfInformation[PartnerUid='" & PartnerUID & "']")
0
 
LVL 27

Expert Comment

by:BigRat
ID: 24860585
The posting "I went the XPath route" corresponds to my suggestion.
0
 
LVL 27

Expert Comment

by:BigRat
ID: 24860587
The posting "I went the XPath route" corresponds to my suggestion.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using Classic ASP inside HTML pages 2 60
xpath sql query 2008 8 53
XSLT Display Label Name 1 22
split XML field into many fields from MS Access 21 27
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question