Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nebie question- writing attribute value 1

Status
Not open for further replies.

AgentM

MIS
Jun 6, 2001
387
US
Can anybody tell me what is the best way to change the attribute value on a particualar node in a axml file ?
Thank you.
Code:
<Vehicle>
<Cars>
<Hybirds id='Toyota' cost='2500'>Available</Hybrids>
<Hybrids id='Honda' cost='3500'>Available</Hybrids>
</Cars>
I want to change the value for cost where the id ='Honda'
Thank you.
 
look into the XmlDocument object and XPath queries.
Code:
XmlNodes[] nodes = new XMLDocument.LoadXml("xml string").SelectNodes("\\[@id='Honda']");
foreach(XmlNode node in nodes)
{
   node.Attribute["cost"].Value = newCost;
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top