Solved

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

Posted on 2009-07-02
5
1,931 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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