Hi,
I am reading an xml document which has companies information like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<Companies>
<Company>
<CustomerNo><![CDATA[67]]></CustomerNo>
<CompanyName><![CDATA[ABC lead]]></CompanyName>
<Address><![CDATA[888 homme way]]></Address>
<Zip><![CDATA[94520]]></Zip>
<City><![CDATA[San Jose]]></City>
<State><![CDATA[California]]></State>
<Country><![CDATA[USA]]></Country>
<Phone><![CDATA[898-989-8988]]></Phone>
<Fax><![CDATA[565-565-5655]]></Fax>
<Email><![CDATA[jsmith@abc.com]]></Email>
<Custom_2><![CDATA[]]></Custom_2>
<Custom_5><![CDATA[]]></Custom_5>
<CustomerTypeText2><![CDATA[DownloadPlus]]></CustomerTypeText2>
<Custom_11><![CDATA[]]></Custom_11>
<Custom_12><![CDATA[]]></Custom_12>
<Custom_1><![CDATA[0]]></Custom_1>
<Custom_3><![CDATA[]]></Custom_3>
<Custom_9><![CDATA[]]></Custom_9>
<Custom_8><![CDATA[]]></Custom_8>
<Custom_6><![CDATA[]]></Custom_6>
<Custom_7><![CDATA[]]></Custom_7>
<Custom_4><![CDATA[]]></Custom_4>
<Custom_10><![CDATA[]]></Custom_10>
</Company>
<Comapny 2>
...
</Comapny 2>
</Companies>
I read each company information like so:
Code:
private void ReadXmlData(string xmlSource)
{
XmlNodeList list = null;
XmlDocument xdoc = new XmlDocument();
xdoc.Load(xmlSource);
list = xdoc.GetElementsByTagName("Company");
foreach (XmlNode node in list)
{
....
}
The variable 'node' gives me each company with it's child elements.
The thing that I am not able to do is add a new node to the 'node' variable.
For instance in the first run I have the following information in the 'node' variable.
Code:
<Company>
<CustomerNo><![CDATA[67]]></CustomerNo>
<CompanyName><![CDATA[ABC lead]]></CompanyName>
<Address><![CDATA[888 homme way]]></Address>
<Zip><![CDATA[94520]]></Zip>
<City><![CDATA[San Jose]]></City>
<State><![CDATA[California]]></State>
<Country><![CDATA[USA]]></Country>
<Phone><![CDATA[898-989-8988]]></Phone>
<Fax><![CDATA[565-565-5655]]></Fax>
<Email><![CDATA[jsmith@abc.com]]></Email>
<Custom_2><![CDATA[]]></Custom_2>
<Custom_5><![CDATA[]]></Custom_5>
<CustomerTypeText2><![CDATA[DownloadPlus]]></CustomerTypeText2>
<Custom_11><![CDATA[]]></Custom_11>
<Custom_12><![CDATA[]]></Custom_12>
<Custom_1><![CDATA[0]]></Custom_1>
<Custom_3><![CDATA[]]></Custom_3>
<Custom_9><![CDATA[]]></Custom_9>
<Custom_8><![CDATA[]]></Custom_8>
<Custom_6><![CDATA[]]></Custom_6>
<Custom_7><![CDATA[]]></Custom_7>
<Custom_4><![CDATA[]]></Custom_4>
<Custom_10><![CDATA[]]></Custom_10>
</Company>
To this I want to add a 'CustomerID' node.
How to go about it.
Any help is greatly appreciated.