Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XPATH

0 views
Skip to first unread message

CK

unread,
Dec 15, 2004, 5:19:14 AM12/15/04
to
I Load the xml into the xmldoc and work with it fine. in the middle of my
function I do a xpath to get two nodes that are similar.

<X12_4010_837>
<TS837Q3_2000A>
<testvalue_AB>ck</testvalue_AB>
<TS837Q3_2000B>
<testvalue abc="testing this1">
</testvalue>

</TS837Q3_2000B>

<TS837Q3_2000B>
<testvalue abc="testing this2">
</testvalue>
</TS837Q3_2000B>
</TS837Q3_2000B>
</TS837Q3_2000A>
</X12_4010_837>

My Questions: 1) if I do SelectSingleNode(XPathFld) Does this give me both
of the nodes??? if not how can I get both nodes????

2)how can I walk through both nodes and list
the value of the attributes?????

I apprecite if some one could hep me with the
code.

Thank in advance

Public string myfunc(string strxml)

{

System.Xml.XmlDocument xmlDoc = new XmlDocument();

xmlDoc.LoadXml(strInXml);

...............

/

XPathFld=(/X12_4010_837/TS837Q3_2000A/TS837Q3_2000B/testvalue/@abc);

nFld = xmlDoc.SelectSingleNode(XPathFld);

string Code="";

if(nFld !=null)

{


Code=nFld.Value;

}

}


Oleg Tkachenko [MVP]

unread,
Dec 15, 2004, 5:47:07 AM12/15/04
to
CK wrote:

> My Questions: 1) if I do SelectSingleNode(XPathFld) Does this give me both
> of the nodes??? if not how can I get both nodes????

SelectSingleNode() method selects single node as can guess from its name.
To select both use SelectNodes() method.

>
> 2)how can I walk through both nodes and list
> the value of the attributes?????

Take a look at SelectNodes() method documentation - that's pretty trivial.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com

0 new messages