PDA

View Full Version : XML Get Attribute


NickT
08-18-2005, 01:28 PM
Hi. Currently I am evaluating True Update for a project my company is working on. I have been impressed by its easy to use interface and strong features.

However, I am having trouble understanding how the XML.GetAttribute action works. I have an XML file that I need to read from. It's format is very similar to the one below. How would I extract the "Value" of the "ServerLocation" attribute?

serverPath = XML.GetAttribute("ItemSearchResponse/OperationRequest/Arguments/Argument Name", "Value");??


<?xml version="1.0" encoding="UTF-8" ?>
<ItemSearchResponse>
<OperationRequest>
<Arguments>
<Argument Name="Service" Value="AWSECommerceService" />
<Argument Name="ItemPage" Value="11" />
<Argument Name="ServerLocation" Value="\\server\share" />
</Arguments>
</OperationRequest>
</ItemSearchResponse>
THANKS :)

NickT
08-18-2005, 01:58 PM
I answered my own question :p
The code is:
serverPath = XML.GetAttribute("ItemSearchResponse/OperationRequest/Arguments/Argument Name:3", "Value");

Corey
08-18-2005, 02:01 PM
Excellent! Thanks for posting your answer so others can benefit from it. :)

Lorne
08-18-2005, 04:01 PM
I answered my own question :p
The code is:
serverPath = XML.GetAttribute("ItemSearchResponse/OperationRequest/Arguments/Argument Name:3", "Value");
Careful...I think you should actually be using:
serverPath = XML.GetAttribute("ItemSearchResponse/OperationRequest/Arguments/Argument:3", "Value");...since Name is an attribute, and the name of the element is "Argument" and not "Argument Name." :)

NickT
08-22-2005, 10:16 AM
Hey - thanks for the reply!

Careful...I think you should actually be using:
serverPath = XML.GetAttribute("ItemSearchResponse/OperationRequest/Arguments/Argument:3", "Value");...since Name is an attribute, and the name of the element is "Argument" and not "Argument Name." :)

Your code does make more sense than mine. Oddly, when I retested both statements, they both produced the same result. :p However, I will change my code to the statement you suggested.
Thanks!