.appendchild (xesub2 );Xmlelement xesub3 = xmldoc. createelement ("price ");Xesub3.innertext = "158.3 ";Xe1.appendchild (xesub3 );
Root. appendchild (xe1); // Add it to the Xmldoc. Save (server. mappath ("data. xml "));
//////////////////////////////////////// //////////////////////////////////////// //////Result: A node is added to the original XML content. The content is as follows,
3. Modify the node value (attributes and subnodes ):
Xmldocument xmldoc = new xmldocument ();Xmldoc. Load
nodeXe1.AppendChild (xesub1); // Add it to the XmlElement xesub2 = xmlDoc. CreateElement ("author ");Xesub2.InnerText = "master ";Xe1.AppendChild (xesub2 );XmlElement xesub3 = xmlDoc. CreateElement ("price ");Xesub3.InnerText = "158.3 ";Xe1.AppendChild (xesub3 );
Root. AppendChild (xe1); // Add it to the XmlDoc. Save (Server. MapPath ("data. xml "));
//////////////////////////////////////// //////////////////////////////////////// //////Result: A node is added to the original xml content. The c
";/Set Text nodeXe1. AppendChild (XESUB1);//Add to XmlElement xesub2=xmldoc.createelement ("author");Xesub2. innertext= "Hou Jie";Xe1. AppendChild (XESUB2);XmlElement xesub3=xmldoc.createelement ("price");Xesub3. innertext= "58.3";Xe1. AppendChild (XESUB3);Root. AppendChild (XE1);//Add to Xmldoc.save ("Bookstore.xml");
//================The results are:
2, modify the node: The genre property value of "Li Zhanhong" node genre value changed to "Update Li Zha
a text nodeXe1.AppendChild (xesub1); // Add it to the XmlElement xesub2 = xmlDoc. CreateElement ("author ");Xesub2.InnerText = "master ";Xe1.AppendChild (xesub2 );XmlElement xesub3 = xmlDoc. CreateElement ("price ");Xesub3.InnerText = "158.3 ";Xe1.AppendChild (xesub3 );
Root. AppendChild (xe1); // Add it to the XmlDoc. Save (Server. MapPath ("data. xml "));
//////////////////////////////////////// //////////////////////////////////////// //////Result: A node is added to the original xml content
(xesub3 );
Root. appendchild (xe1); // Add it to the Xmldoc. Save (server. mappath ("data. xml "));
//////////////////////////////////////// //////////////////////////////////////// //////Result: A node is added to the original XML content. The content is as follows,
3. Modify the node value (attributes and subnodes ):
Xmldocument xmldoc = new xmldocument ();Xmldoc. Load (server. mappath ("data. xml "));
Xmlnodelist nodelist = xmldoc. selectsinglenode ("employees"). childnodes; // obtai
(XESUB3);Root. AppendChild (XE1);//Add to Xmldoc.save (Server.MapPath ("Data.xml"));//////////////////////////////////////////////////////////////////////////////////////Result: A node is added to the original XML content as follows,3, modify the value of the node (attributes and sub-nodes):XmlDocument xmldoc=new XmlDocument ();Xmldoc.load (Server.MapPath ("Data.xml"));XmlNodeList Nodelist=xmldoc.selectsinglenode ("Employees"). childnodes;//get all child nodes of the Employees nodeforeach (XmlN
(xe1); // Add it to the Xmldoc. Save (server. mappath ("data. xml "));
//////////////////////////////////////// //////////////////////////////////////// //////Result: A node is added to the original XML content. The content is as follows,
3. Modify the node value (attributes and subnodes ):
Xmldocument xmldoc = new xmldocument ();Xmldoc. Load (server. mappath ("data. xml "));
Xmlnodelist nodelist = xmldoc. selectsinglenode ("employees"). childnodes; // obtain all child nodes of the employ
");Xesub3.innertext = "158.3 ";Xe1.appendchild (xesub3 );
Root. appendchild (xe1); // Add it to the Xmldoc. Save (server. mappath ("data. xml "));
//////////////////////////////////////// //////////////////////////////////////// //////Result: A node is added to the original XML content. The content is as follows,
3. Modify the node value (attributes and subnodes ):
Xmldocument xmldoc = new xmldocument ();Xmldoc. Load (server. mappath ("data. xml "));
Xmlnodelist nodelist = xmldoc. selec
"));
//////////////////////////////////////// ////////
Result: A node is added to the original xml content. The content is as follows,
3. Modify the node value (attributes and subnodes ):
XmlDocument xmlDoc = new XmlDocument ();XmlDoc. Load (Server. MapPath ("data. xml "));
XmlNodeList nodeList = xmlDoc. SelectSingleNode ("Employees"). ChildNodes; // obtain all child nodes of the Employees Node
Foreach (XmlNode xn in nodeList) // traverses all subnodes{XmlElement
first, the environment preparation1.1. DescriptionWorking path/data/hdfs/data1/jianxin/1.2. Software versionOracle-xe-11.2.0-1.0.x86_64.rpm.zip1.3, modify the Tmpfs1.3.1, Oracle XE gives the minimum requirements in the Init.ora file, which is 1G by default. This expands the TMPFS to 2G:To Modify the/etc/fstab file:tmpfs/dev/shm tmpfs defaults 0 0modified to:tmpfs/dev/shm tmpfs defaults,size=2048m 0 01.3.2,
converted to an element to make it easy to get the attribute value of the node XmlElement XE = (XmlElement) xn1; Gets the property value of type and ISBN two properties bookmodel.bookisbn = Xe. GetAttribute ("ISBN").
ToString (); Bookmodel.booktype = Xe. GetAttribute ("Type").
ToString (); Gets all the child nodes of the book node XmlNodeList xnl0 =
"; xe1.AppendChild (xesub3); root. appendChild (xe1); // add
XmlDoc. Save ("E: \ bookstore. xml ");
The modified xml file is:
Oberon's LegacyCorets, Eva
5.95
CS from entry to entryHou Jie
58.3
2. modify the node: change the genre value of the node whose genre attribute value is "Li zanxiang" to "update Li zanxiang", and change the text of the child node of the node to "Yashe
zenhong" to "Update Li zenhong ", modify the text of the child node
Xmlnodelist nodelist = xmldoc. selectsinglenode ("Bookstore"). childnodes; // obtain all the subnodes of the bookstore NodeForeach (xmlnode Xn in nodelist) // traverses all subnodes{Xmlelement Xe = (xmlelement) xn; // converts the subnode type to the xmlelement typeIf (Xe. getattribute ("genre") = "") // If the genre attribute value is
, eva
5.95
Cs from entry to mastery
Hou Jie
58.3
2. Modify the node: Change the genre value of the node whose genre attribute value is "Li zenhong" to "Update Li zenhong ", modify the text of the child node Xmlnodelist nodelist = xmldoc. selectsinglenode ("Bookstore"). childnodes; // obtain all the subnodes
child nodes of the bookstore node foreach (XmlNode xn in nodeList)//traverse all child nodes {XmlElement xe= (XmlElement) xn;//the child node class Type to XmlElement if (XE). GetAttribute ("genre") = = "Li Zhanhong")//if the genre attribute value is "Li Zhanhong" {Xe. SetAttribute ("Genre", "Update Li Zhanhong");//Modify this property to "Update Li Zhanhong"Xml
");
// ================================================ ==========
Result:2. Modify the node: Change the genre value of the node whose genre attribute value is "Li zenhong" to "Update Li zenhong ", modify the text of the child node
Xmlnodelist nodelist = xmldoc. selectsinglenode ("Bookstore"). childnodes; // obtain all the subnodes of the bookstore Node
Foreach (xmlnode Xn in nodelist) // traverses all subnodes
{
Xmlelement Xe = (xmlelement) xn; //
", modify the text of the child node
Xmlnodelist nodelist = xmldoc. selectsinglenode ("Bookstore"). childnodes; // obtain all the subnodes of the bookstore NodeForeach (xmlnode Xn in nodelist) // traverses all subnodes{Xmlelement Xe = (xmlelement) xn; // converts the subnode type to the xmlelement typeIf (Xe. getattribute ("genre") = "") // If the genre attribute value is ""{
("bookstore"). ChildNodes; // obtain all the subnodes of the bookstore NodeForeach (XmlNode xn in nodeList) // traverses all subnodes{XmlElement xe = (XmlElement) xn; // converts the subnode type to the XmlElement typeIf (xe. GetAttribute ("genre") = "") // if the genre attribute value is ""{Xe. SetAttribute ("genre", "update lizan red"); // you can change this
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.