BizTalk Server General - xpath question

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > November 2004 > xpath question





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]

Author xpath question
Cindy Liu

2004-11-11, 5:49 pm

Hi,

I have the following Biztalk message:

<?xml version="1.0" encoding="utf-8"?>
<DataChanged xmlns="http://Remoting.schemas/">
<sender>null</sender>
<oData>
<LmxData>
<hashtable>
<item>
<key>GenerationUnit_001.Xtra1</key>
<value>
<GalaxyName>TucsonDev</GalaxyName>
</value>
</item>
<item>
<key>GenerationUnit_001.Xtra2</key>
<value>
<GalaxyName>TucsonDev1</GalaxyName>
</value>
</item>
</hashtable>
</LmxData>
</oData>
</DataChanged>

I used xpath to count <GalaxyName> node and got the correct number 2.
However, when I used xpath to get the data of first <GalaxyName> node, I
always got empty string. Here is my code in Biztalk expression:

oDom=MsgCallback;
strNamespace=oDom.DocumentElement.NamespaceURI;
strXPath="count(//*[local-name()='value' and
namespace-uri()='"+strNamespace+"'])";
nNumOfItems = System.Convert.ToInt32(xpath(MsgCallback, strXPath));

strXPath="string(//*[local-name()='GalaxyName[1]' and
namespace-uri()='"+strNamespace+"'])";
strGalaxy=xpath(MsgCallback,strXPath);

Why strGalaxy is empty? Any idea?

Thanks in advance!!!
Cindy
Stephen W. Thomas

2004-11-11, 5:49 pm

Hello.

Your 2nd XPath should look like this:

strXPath="string(//*[local-name()='GalaxyName'
and namespace-uri()='"+strNamespace+"'][1])";

If you need to loop over them, you need to use String.Format to generate the
xpath string. I have a sample on my blog if that is your final goal.

Hope this helps.

Stephen W. Thomas
http://www.geekswithblogs.net/sthomas


"Cindy Liu" wrote:

> Hi,
>
> I have the following Biztalk message:
>
> <?xml version="1.0" encoding="utf-8"?>
> <DataChanged xmlns="http://Remoting.schemas/">
> <sender>null</sender>
> <oData>
> <LmxData>
> <hashtable>
> <item>
> <key>GenerationUnit_001.Xtra1</key>
> <value>
> <GalaxyName>TucsonDev</GalaxyName>
> </value>
> </item>
> <item>
> <key>GenerationUnit_001.Xtra2</key>
> <value>
> <GalaxyName>TucsonDev1</GalaxyName>
> </value>
> </item>
> </hashtable>
> </LmxData>
> </oData>
> </DataChanged>
>
> I used xpath to count <GalaxyName> node and got the correct number 2.
> However, when I used xpath to get the data of first <GalaxyName> node, I
> always got empty string. Here is my code in Biztalk expression:
>
> oDom=MsgCallback;
> strNamespace=oDom.DocumentElement.NamespaceURI;
> strXPath="count(//*[local-name()='value' and
> namespace-uri()='"+strNamespace+"'])";
> nNumOfItems = System.Convert.ToInt32(xpath(MsgCallback, strXPath));
>
> strXPath="string(//*[local-name()='GalaxyName[1]' and
> namespace-uri()='"+strNamespace+"'])";
> strGalaxy=xpath(MsgCallback,strXPath);
>
> Why strGalaxy is empty? Any idea?
>
> Thanks in advance!!!
> Cindy

Cindy Liu

2004-11-12, 5:48 pm

Thanks Stephen. I figured it out too.
Cindy

"Stephen W. Thomas" wrote:
[vbcol=seagreen]
> Hello.
>
> Your 2nd XPath should look like this:
>
> strXPath="string(//*[local-name()='GalaxyName'
> and namespace-uri()='"+strNamespace+"'][1])";
>
> If you need to loop over them, you need to use String.Format to generate the
> xpath string. I have a sample on my blog if that is your final goal.
>
> Hope this helps.
>
> Stephen W. Thomas
> http://www.geekswithblogs.net/sthomas
>
>
> "Cindy Liu" wrote:
>
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com