|
Home > Archive > BizTalk Server Orchestration > December 2005 > Xpath Expression
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Namshub 2005-12-02, 5:51 pm |
| If I have the following Document loaded in an XML Document Variable, what is
the correct Xpath Query to extract the StatusValue
I tried xpath(PasOut,"string(@StatusValue)") but this only returns an ""
after about 3 hours of testing (as i had know just typing @StatusValue in
stylus studio returns "0" so i thought my code was all correct but my
branching failed and this is the culprit.)
<?xml version="1.0" encoding="utf-16"?>
<PASData StatusValue="0" StatusDescription="SUCCESS">
<PASTransaction>
<TransactionDate>20051129</TransactionDate>
<TransactionID>32109</TransactionID>
<Event>PMIA</Event>
<EventType>A</EventType>
<TransactionTime>121408</TransactionTime>
......
</PASTransaction>
</PASData>
| |
| Scott Colestock 2005-12-02, 5:51 pm |
| If you want just the "zero" (the attribute value) use
status = xpath(PasOut,"string(/PASData/@StatusValue)");
Scott Colestock
www.traceofthought.net
"Namshub" <Ricchard.Pullen@Southend.nhs.uk.RemoveMyspam> wrote in message
news:O69PSL19FHA.320@TK2MSFTNGP10.phx.gbl...
> If I have the following Document loaded in an XML Document Variable, what
> is the correct Xpath Query to extract the StatusValue
> I tried xpath(PasOut,"string(@StatusValue)") but this only returns an ""
> after about 3 hours of testing (as i had know just typing @StatusValue in
> stylus studio returns "0" so i thought my code was all correct but my
> branching failed and this is the culprit.)
>
>
> <?xml version="1.0" encoding="utf-16"?>
> <PASData StatusValue="0" StatusDescription="SUCCESS">
> <PASTransaction>
> <TransactionDate>20051129</TransactionDate>
> <TransactionID>32109</TransactionID>
> <Event>PMIA</Event>
> <EventType>A</EventType>
> <TransactionTime>121408</TransactionTime>
> .....
> </PASTransaction>
> </PASData>
>
>
| |
| Marian Drumea 2005-12-03, 2:47 am |
| A very nice trick when you need the XPath to access a certain node in a
complex or simple schema is to go to the XSD file in your BizTalk
project, select the node you want, and get the value of the "Instance
XPath" property out of the properties window. Then, you can use it in
your Expression shapes or such. It's the long version, but you can use
a nice copy and paste without even looking into the string. For when
you want to be able to select a node out of many based on an index,
split the expression with something like [" + indexVariable + "]. Just
in case.
Thanks,
Marian
http://www.MarianDrumea.com/BizTalk
| |
| Neal Walters 2005-12-05, 5:55 pm |
| Always test your XPath outside of Biztalk first (to make sure it is correct).
Suggested tools: Stylus Studio (it will even generate the xpath for you),
XmlSpy, and there are also free tools, or you can code it in C# or VB.NET.
There are even JavaScript programs to help people learn XPath that run in the
browser. You can usually paste your Xpath in one window, and paste your XML
in the other.
Neal Walters
http://Biztalk-Training.com
|
|
|
|
|