Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-07-02
5
Medium Priority
?
1,967 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

610 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