[
Lists Home |
Date Index |
Thread Index
]
- To: "Mattison" <peacock@panix.com>,<xml-dev@lists.xml.org>
- Subject: RE: [xml-dev] XML.Net find node by content and change attribute
- From: "Dare Obasanjo" <dareo@microsoft.com>
- Date: Wed, 27 Aug 2003 09:25:45 -0700
- Thread-index: AcNsDQGNDdoYpEjtTnmoviJwfuKcwAAqtyhA
- Thread-topic: [xml-dev] XML.Net find node by content and change attribute
I'm not sure whether XML.Net means the classes in the System.Xml namespace of the .NET Framework or not. If so the FindElementWithValue method you are looking for is called SelectSingleNode and it uses XPath (good tutorial at http://www.zvon.org/xxl/XPathTutorial/General/examples.html)
________________________________
From: Mattison [mailto:peacock@panix.com]
Sent: Tue 8/26/2003 1:01 PM
To: xml-dev@lists.xml.org
Subject: [xml-dev] XML.Net find node by content and change attribute
Greetings
I'm trying to build a nav bar from an xml file. I've got an xml file as
below sitting on the server. I'm using XML.Net and what I want to do is
load in the page, then find the "Page" node that contains a
"<name>$current_page</name>" node. Then create an attribute (active) on
the Page tag.
What I haven't figure a good way to do is what XML.net objects and methods
I need to locate the node the node I want.
<NavList>
<Page>
<url>contact.asp</url>
<name>Contacts</name>
</Page>
<Page>
<url>rel.asp</url>
<name>Providers</name>
</Page>
<Page>
<url>incident.asp</url>
<name>Incidents</name>
</Page>
<Page>
<url>lit.asp</url>
<name>Correspondence</name>
</Page>
</NavList>
// psuedo code
XDoc.Load(m_server.MapPath(nav_file));
// this is the code I don't know how to do
XmlElement Xname = XDoc.FindElementWithValue("Page/name", current);
XmlElement XPage = Xname.ParentElement();
// end unknown
XElement.SetAttribute("active", 1);
Thanks for any help.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Mattison Narramore peacock@panix.com +
+-----------------------------------------------------------------+
+ The most likely way for the world to be destroyed, most experts +
+ agree, is by accident. That's where we come in; we're computer +
+ professionals. We cause accidents. +
+ -Nathaniel Borenstein +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>
The list archives are at http://lists.xml.org/archives/xml-dev/
To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>
|