hi,
the following code should help. It gets a nodeset of the Report nodes with
the matching id and then iterates over each Report node and gets the nodeset
of all the attributes under the Columns node for that Report node and
concatenates them
Function test3()
Dim xPathDoc As New XPathDocument(FileName)
Dim xPathNav As XPathNavigator = xPathDoc.CreateNavigator()
Dim xPathItr As XPathNodeIterator
xPathItr = xPathNav.Select("Reports/Report[@id='testReport']")
Dim str As String
Do While xPathItr.MoveNext
Dim xPathNavTemp As XPathNavigator
xPathNavTemp = xPathItr.Current
Dim xPathItrTemp As XPathNodeIterator
xPathItrTemp = xPathNavTemp.Select("./Columns/Column/@*")
Do While xPathItrTemp.MoveNext
str = str & xPathItrTemp.Current.Value
Loop
Loop
Console.WriteLine(str)
End Function
hope this helps,
swapna
[quoted text, click to view] <jainamber@gmail.com> wrote in message
news:1135027754.242474.3340@g43g2000cwa.googlegroups.com...
> Hi,
> I am using this code to search on the id attribute of the
> Report element in this XML fragment. If I find a match for the id, then
> I need to return the value of the attributes of the child column for
> each column.
> The code I have written is not working and I do not have a clue about
> what to do next.
>
> Here is the XML document.
>
> <?xml version="1.0"?>
> <Reports>
> <Report id="testReport">
> <SP id="DSMM_TestReport" />
> <Columns>
> <Column id="Id" visible="false" />
> <Column id="Description" visible="true" />
> </Columns>
> </Report>
> <Report id="testReport1">
> <SP id="DSMM_TestReport1" />
> <Columns>
> <Column id="Id1" visible="false" />
> <Column id="Description1" visible="true" />
> </Columns>
> </Report>
> </Reports>
>
>
>
> Here is the code that I am using:
>
> Dim xPathDoc As New XPathDocument(FileName)
> Dim xPathNav As XPathNavigator = xPathDoc.CreateNavigator()
> Dim xPathItr As XPathNodeIterator
> xPathItr =
> xPathNav.Select("Reports[Report[@id='testReport']]/@id")
> Dim str As String
> Do While xPathItr.MoveNext
> str = str & xPathItr.Current.Value
> Loop
>
>
> If you know of any other way using XpathNav to do the same, please let
> me know.
>
> Any help is greatly appreciated.
>
> Thanks,
>
> Amber
>