Sample XML File
[sourcecode language="xml"]
<?xml version="1.0" encoding="utf-8"?>
<DoctorInfo>
<Doctor>
<id>01</id>
<name>Ranil Jayaweera</name>
<speciality>GI</speciality>
</Doctor>
<Doctor>
<id>02</id>
<name>Aruna Gunathilaka</name>
<speciality>VP</speciality>
</Doctor>
<Doctor>
<id>03</id>
<name>Jaya Palipana</name>
<speciality>VOG</speciality>
</Doctor>
</DoctorInfo>
[/sourcecode]
The Code
[sourcecode language="csharp"]
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Application.StartupPath + "\\DoctorsList.xml");
XmlElement subroot = xmlDoc.CreateElement("Doctor");
XmlElement childElementId = xmlDoc.CreateElement("id");
XmlText xmlTextId = xmlDoc.CreateTextNode(txtid.Text);
childElementId.AppendChild(xmlTextId);
subroot.AppendChild(childElementId);
xmlDoc.DocumentElement.AppendChild(subroot);
XmlElement childElementName = xmlDoc.CreateElement("name");
XmlText xmlTextName = xmlDoc.CreateTextNode(txtName.Text);
childElementName.AppendChild(xmlTextName);
subroot.AppendChild(childElementName);
xmlDoc.DocumentElement.AppendChild(subroot);
XmlElement childElementSpeciality = xmlDoc.CreateElement("speciality");
XmlText xmlTextSpeciality = xmlDoc.CreateTextNode(cbspecial.Text);
childElementSpeciality.AppendChild(xmlTextSpeciality);
subroot.AppendChild(childElementSpeciality);
xmlDoc.DocumentElement.AppendChild(subroot);
xmlDoc.Save(Application.StartupPath + "\\DoctorsList.xml");
[/sourcecode]
Subscribe to:
Post Comments (Atom)
How to enable CORS in Laravel 5
https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...
-
< Requirements Java Development Kit (JDK) NetBeans IDE Apache Axis 2 Apache Tomcat Server Main Topics Setup Development Environ...
-
Download Sourcecode [sourcecode language="csharp"] using System; using System.Collections.Generic; using System.Linq; using System...
No comments:
Post a Comment