Re: NEWBIE - How to Replace XML Node Attribute

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Dave (nospam_at_yahoo.com)
Date: 01/24/05

  • Next message: Stan Kitsis [MSFT]: "Re: can't create schema for qualified attributes in element with default namespace"
    Date: Mon, 24 Jan 2005 11:49:24 -0500
    
    

    Dennis,

    Thanks for the reply. I'll give it a shot.

    -Dave

    "Dennis Myrén" <dennis@oslokb.no> wrote in message
    news:SN8Jd.5772$Sl3.135202@news4.e.nsc.no...
    > Try this:
    >
    > XmlDocument doc = new XmlDocument();
    > doc.LoadXml("
    > <configuration>
    > <Section Name="Settings">
    > <Key Name="Setting1" Value="101"></Key>
    > <Key Name="Setting2" Value="202"></Key>
    > <Key Name="Setting3" Value="300"></Key>
    > <Key Name="Setting4" Value="404"></Key>
    > </Section>
    > </configuration>
    > ");
    > // or doc.Load(theFile);
    > XmlNode keyNode =
    > doc.DocumentElement.SelectSingleNode("Section[@Name='Settings']/Key[@Name='Setting3']");
    > // Make sure we found the node.
    > if (keyNode != null)
    > {
    >
    > keyNode.Attributes ["Value"].InnerText = "303";
    > }
    >
    > --
    > Regards,
    > Dennis JD Myrén
    > Oslo Kodebureau
    > "Dave" <nospam@yahoo.com> wrote in message
    > news:%23d8FFfiAFHA.4028@TK2MSFTNGP15.phx.gbl...
    >>I have an XML file:
    >>
    >> <configuration>
    >> <Section Name="Settings">
    >> <Key Name="Setting1" Value="101"></Key>
    >> <Key Name="Setting2" Value="202"></Key>
    >> <Key Name="Setting3" Value="300"></Key>
    >> <Key Name="Setting4" Value="404"></Key>
    >> </Section>
    >> </configuration>
    >>
    >> I want to change the value of "setting3" from "300" to "303."
    >>
    >> Can somebody provide me with code that will allow me to do this?
    >>
    >> Thank you kindly for any help you can provide,
    >>
    >> -Dave
    >>
    >
    >


  • Next message: Stan Kitsis [MSFT]: "Re: can't create schema for qualified attributes in element with default namespace"

    Relevant Pages