Le réseau pour les développeurs > Forums - Accueil > XML Paper Specification (XPS) > how to find the value xml file and update
Poser une questionPoser une question
 

Questionhow to find the value xml file and update

  • mercredi 17 juin 2009 12:53Ranganathan Palanisamy Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     

     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.

Toutes les réponses

  • jeudi 18 juin 2009 06:55Ranganathan Palanisamy Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    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.