Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Attributes

Status
Not open for further replies.

galvin101

Programmer
Aug 17, 2005
6
GB

Hi , I am new to XML and need some help retrieving the order attribute in a ASP Page, I have succesfully got everything else apart from this one attribute, I have found several websites explaing about nodes, but I am not having any luck.

Below is the code and it is in the Search Info section on the SortBy tag.

Any help would be appreciated


<?xml version="1.0" encoding="UTF-8" ?>
- <DistributedSearchXML payloadID="123465678">
- <Header version="1.0">
- <From>
- <Credential domain="DUNS">
<Identity>operations</Identity>
</Credential>
</From>
- <To>
- <Credential domain="Name">
<Identity>Disneyland</Identity>
</Credential>
</To>
- <Login>
<UserName>bob</UserName>
<Password>password</Password>
<AuthenticatedKey>12345678</AuthenticatedKey>
</Login>
</Header>
- <Request>
- <ItemSearchRequest operation="SimpleSearch">
- <UserInfo>
<UserName />
<AppsUserName>ppan</AppsUserName>
<UserPhone />
<UserEmail />
</UserInfo>
- <SearchInfo>
<SearchLanguage>EN-US</SearchLanguage>
<SearchKeywords>blue pen</SearchKeywords>
<SortBy order="DESC">Price</SortBy>
<ResultSize>15</ResultSize>
<StartResult>1</StartResult>
</SearchInfo>
+ <UserArea>
<SupplementalInfo name="Group">OU1</SupplementalInfo>
<SupplementalInfo name="Division">NorthEast</SupplementalInfo>
</UserArea>
</ItemSearchRequest>
</Request>
</DistributedSearchXML>
 
Try

To get the sort by tag use::
<xsl:value-of select="//SortBy"/>

To get the order attribute use:
<xsl:value-of select="//SortBy/@order"/>

(The // means search the document and wherever there is a node called SortBy pick it up. You can be more specific if necessary.)

Good Luck
 
Hi There, thanks for the info,

Im not sure that the XSL is working, I am using an ASP page to read the values of the code I originally posted, to use to post XML back to a client.

I need to run an SQL query using the DESC on the sort by tag, but cant use it as I dont know the VBscript to use to get the value.

thanks
 
If you want to use VB for this the code would be something like:

node = xmlDoc.selectSingleNode("//SortBy/@order")
node.InnerText 'should contain the value of order

You should be able to insert that value into your query.

I am assuming that you have already pulled the xml document and loaded it into the xml document into an XmlDocument object.


Good Luck
 
Right, thanks for that

I have now got this code

1)set temp = XDoc.getElementsByTagName("Request/ItemSearchRequest/SearchInfo/SortBy").Item(0).Attributes.GetNamedItem("order")
2)AttID=temp.text

This doesn't error, nor does it output any values, any idea whats wrong with this?

 
temp.text

Might be your problem try temp.InnerText

I also recomend that you use
.selectSingleNode
rather than getElementsByTagName
because that uses real xpath.

You can also break out your variables and use the debugger to check their values. (To debug an asp page select process from the Debug menu and attach to the asp_ something process.)

Good Luck
 
Top man , thanks for your help on this, solution worked
 
Any time. I learned this very lesson the hard way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top