Determine whether the XML file is in an inch

Source: Internet
Author: User

VaR seg = username; If (file. exists (username + ". xml") // C {string name = "notremindbox ";

Xmldocument xdocs = new xmldocument (); xdocs. load (username + ". XML "); // load the XML file // search for the element xmlnode car = xdocs by ID. selectsinglenode ("// notremindbox [@ name = \" "+ name +" \ "]"); // xmlnode node = xdocs. selectsinglenode ("Aasman/makeannc/field [@ name = 'zone _ maps ']"); xmlelement Xe = (xmlelement) car; // Xe. setattribute ("value", "sdfdf"); // modify the Xe value. innertext = "true"; xdocs. save (username + ". XML ");} else {// instantiate an XML document xmldocument xdoc = new xmldocument (); // instantiate an XML document declaration xmldeclaration xdela = xdoc. createxmldeclaration ("1.0", "UTF-8", "yes"); // Add the declaration to the document xdoc. appendchild (xdela); // create the element user xmlelement user = xdoc. createelement ("user"); // append the user element node to xdoc in the document. appendchild (User );

// No longer prompt notremindboxs xmlelement notremindboxs = xdoc. createelement ("notremindbox"); // The notremindboxs node specifies the text content handler. innertext = "true"; user. appendchild (notremindboxs );

// Add the xmlattribute name = xdoc. createattribute ("name"); Name. value = "donotprompt"; notremindboxs. attributes. append (name); // Add comments // xmlcomment XC = xdoc. createcomment ("this movie is funny"); // movie2.appendchild (XC );

// Save xdoc. Save (username + ". xml");} // string EE = "0013 ";

// Xmldocument xdocs = new xmldocument (); // xdocs. Load ("movies2.xml"); // load the XML file

//// Search for elements by ID // xmlnode car = xdocs. selectsinglenode ("// moviez [@ No = \" "+ EE +" \ "]"); // xmlnode node = xdocs. selectsinglenode ("Aasman/makeannc/field [@ name = 'zone _ maps ']"); // xmlelement Xe = (xmlelement) car; // Xe. setattribute ("value", "sdfdf"); // Xe. innertext = "dfgdfg"; // car ["moviez"]. value = EE + "1"; // xdocs. save ("movies2.xml ");

}

Determine whether the XML file is in an inch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.