[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: 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@p...] Sent: Tue 8/26/2003 1:01 PM To: xml-dev@l... Subject: 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@p... + +-----------------------------------------------------------------+ + 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|