[Home] [By Thread] [By Date] [Recent Entries]

  • To: xml-dev@l...
  • Subject: XML.Net find node by content and change attribute
  • From: Mattison <peacock@p...>
  • Date: Tue, 26 Aug 2003 16:01:39 -0400 (EDT)

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                         +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member