C # create an xml node using winform

Source: Internet
Author: User

C # create an xml node using winform
XmlDocument xmlDoc = new XmlDocument ();
XmlDoc. Load (Help. basePath );

XmlNode root = xmlDoc. SelectSingleNode ("control ");

 

 

 

XmlElement timelock = xmlDoc. CreateElement ("lock ");
XmlElement timelocksub1 = xmlDoc. CreateElement ("islock ");
Timelocksub1.InnerText = checkEditScreenshots. Checked. ToString ();
Timelock. AppendChild (timelocksub1 );


XmlElement timelocksub2 = xmlDoc. CreateElement ("locktime ");
Timelocksub2.InnerText = txtLockTime. Text. Trim ();
Timelock. AppendChild (timelocksub2 );
XmlElement timelocksub3 = xmlDoc. CreateElement ("locktimes ");
Timelocksub3.InnerText = txtLockTimes. Text. Trim ();
Timelock. AppendChild (timelocksub3 );


XmlElement timelocksub4 = xmlDoc. CreateElement ("LockRemConType ");
Timelocksub4.InnerText = Help. LockRemConType. ToString ();
Timelock. AppendChild (timelocksub4 );


XmlElement timelocksub5 = xmlDoc. CreateElement ("LockRemCon ");
Timelocksub5.InnerText = richTxtLockCon. Text. Trim ();
Timelock. AppendChild (timelocksub5 );


Root. AppendChild (timelock );

XmlDoc. Save (Help. basePath );

 

 

Help. basePath ------------------------ file storage path

Control ---------------------- Root Node

"" Is the name of the node you want to create and can be defined by yourself.

Make sure to Save xmlDoc. Save (Help. basePath );

Related Article

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.