Solved

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

Posted on 2009-07-02
5
1,943 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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

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…
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. 
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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