Groups | Blog | Home
all groups > dotnet xml > march 2005 >

dotnet xml : Problems retrieving data from XML file



Nancy Shelley
3/4/2005 12:22:55 PM
Hi all,

I have been having problems trying to retrieve data from my xml file. What
I am trying to do is select a certain group node based on its groupid value.
When I have that node I want to select all the menu nodes related to that
group that have a value=1 along with its items that have a value=1. I have
been trying an xpath query but with no luck. I have included one of the
queries I have been trying.

Any help would be greatly appreciated!

strExpression = "/configuration/groups/group/menus/menu/menuname[../@value=1
and ../@groupid= " & GroupID & "]"


This is my xml document structure:

<configuration>
<groups>
<group groupid="1" templateid="1">
<groupname>Primary French Immersion</groupname>
<menus>
<menu menuid="1" value="1" menuname="Resources">
<item name="Preparation and Planning" menuid="4" value="1" />
<item name="Parking Arrangments" menuid="5" value="0" />
<item name="Agendas" menuid="6" value="1" />
</menu>
<menu menuid="2" value="0" menuname="Communications">
<item name="Discussion Forum" menuid="1" value="0" />
<item name="Eluminate Live" menuid="2" value="0" />
</menu>
<menu menuid="10" value="1" menuname="Professional Development">
<item name="Course Specific" menuid="11" value="0" />
<item name="In-Service Materials" menuid="12" value="1" />
</menu>
</menus>
</group>
<group groupid="3" templateid="3">
<groupname>Core French</groupname>
<menus>
<menu menuid="1" value="0" menuname="Resources">
<item name="Preparation and Planning" menuid="4" value="0" />
<item name="Parking Arrangments" menuid="5" value="0" />
<item name="Agendas" menuid="6" value="0" />
</menu>
<menu menuid="2" value="0" menuname="Communications">
<item name="Discussion Forum" menuid="1" value="0" />
<item name="Eluminate Live" menuid="2" value="0" />
</menu>
<menu menuid="10" value="1" menuname="Professional Development">
<item name="Course Specific" menuid="11" value="1" />
<item name="In-Service Materials" menuid="12" value="0" />
</menu>
</menus>
</group>
</groups>
</configuration>


Nancy Shelley
3/4/2005 1:17:36 PM
woo hoo it worked - well with one slight modification
strExpression = "/configuration/groups/group[@groupid= " & GroupID &
"]/menus/menu[@value = 1]/@menuname"

Thank you so much!!



[quoted text, click to view]

Martin Honnen
3/4/2005 5:24:31 PM


[quoted text, click to view]


[quoted text, click to view]

You can apply a predicate anywhere in your XPath expression so you
likely want
strExpression = "/configuration/groups/group[groupid = " & GroupID &
"]/menus/menu[@value = 1]/@menuname"

--

Martin Honnen
AddThis Social Bookmark Button