MSDN > Home page del forum > XML Paper Specification (XPS) > how to find the value xml file and update
Formula una domandaFormula una domanda
 

Domandahow to find the value xml file and update

  • mercoledì 17 giugno 2009 12.53Ranganathan Palanisamy Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     

     Hi Expects

                        How to find the particular value particular value and update  particular xml element value in asp.net in c#.net

     xml format

     <paddress>
        <autoid>0</autoid>
        <fname>Ranganathan</fname>
        <lname>palanisamy</lname>
        <address>bangalore</address>
        <mobile>9886974230</mobile>
        <phone>04295287563</phone>
        <mail>ranganathan@gmail.com</mail>
      </paddress>

    my problem is 

       programming wise find <autoid> and how to update fname,lname,address,mobile,phone & mail

     plz share the example code

    thanks for sharing  your knowelege
    Ranganathan.P., Software Developer., Bangalore India.

Tutte le risposte

  • giovedì 18 giugno 2009 6.55Ranganathan Palanisamy Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    thnaks for viewers

    i got solution

       XmlDocument doc = new XmlDocument();
    doc.Load("C:\\YourXmlFile.xml");
    XmlNodeList nodes = doc.GetElementsByTagName("autoid");

    foreach (XmlNode node in nodes)
    {
    if (node.InnerText == "0")//If autoid is 0
    {
    XmlNode ParentNode = node.ParentNode;
    string[] strNewList = {"autoid","newfname","newlname","newAddress","newMobile","newPhone","newMail"};
    for (int i = 1; i < ParentNode.ChildNodes.Count; i++)
    {
    node.ParentNode.ChildNodes[i].InnerText = strNewList[i];
    }
    }
    }
    doc.Save("C:\\YourXmlFile.xml");

    Ranganathan.P., Software Developer., Bangalore India.