[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

  • To: "Mattison" <peacock@p...>,<xml-dev@l...>
  • Subject: RE: XML.Net find node by content and change attribute
  • From: "Dare Obasanjo" <dareo@m...>
  • Date: Wed, 27 Aug 2003 09:25:45 -0700
  • Thread-index: AcNsDQGNDdoYpEjtTnmoviJwfuKcwAAqtyhA
  • Thread-topic: XML.Net find node by content and change attribute

xml find node
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.