Solved

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

Posted on 2009-07-02
5
1,916 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
Comment Utility
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
Comment Utility
I went the XPATH route

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

Expert Comment

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

Expert Comment

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now