This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > March 2005 > How to get XPath expr for the Xml with xmlns="http://tempuri.org/"





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 How to get XPath expr for the Xml with xmlns="http://tempuri.org/"
Suraaj Vyas

2005-03-14, 6:40 pm

Hello guys,

<?xml version=\"1.0\" encoding=\"utf-16\"?>
<Inventory xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
<name xmlns=\"http://tempuri.org/\">Macho man </name>
<eventInfo xmlns=\"http://tempuri.org/\">
<venueName>Circus</venueName>
<talent>
<anyType xsi:type=\"EventTalentInfo\">
<id>0</id>
</anyType>
</talent>
</eventInfo>
</Inventory>

In the above XML file I want to get the values of the nodes but I am not
able to find a suitable XPath expression for name , venueName.

object obj = doc.CreateNavigator().Evaluate(XPath Expression);

if (obj is XPathNodeIterator)
{
XPathNodeIterator it = (XPathNodeIterator) obj;
it.MoveNext();
txt = it.Current.ToString();
}

Please help me for getting tht expression and if you can tell me that how
can I get the XPath expression from the tag name so that i can cross check
with what value I am using for a certain tag name

Secondly you can see the weak typing the XML Serializer has done as there
are fields with "anyType" as the name . Please let me know how can I strong
type the XML to get the actual types there.

Thanx for any help I get from you guys.

Suraaj

Martin Honnen

2005-03-15, 6:48 pm



Suraaj Vyas wrote:


> <?xml version=\"1.0\" encoding=\"utf-16\"?>
> <Inventory xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
> xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
> <name xmlns=\"http://tempuri.org/\">Macho man </name>
> <eventInfo xmlns=\"http://tempuri.org/\">
> <venueName>Circus</venueName>
> <talent>
> <anyType xsi:type=\"EventTalentInfo\">
> <id>0</id>
> </anyType>
> </talent>
> </eventInfo>
> </Inventory>
>
> In the above XML file I want to get the values of the nodes but I am not
> able to find a suitable XPath expression for name , venueName.


See
<http://www.faqts.com/knowledge_base...d/34022/fid/616>
on how to bind a prefix to the default namespace and then use that
prefix in the XPath expression.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews