my XML FILE:<ITPL>
<GATE NAME='2'>
<Slot sno='5'>slot no=5, type=4,VACANT</Slot>
<Slot sno='6'>slot no=6, type=4,VACANT</Slot>
<Slot sno='7'>slot no=7, type=2,VACANT</Slot>
<Slot sno='8'>slot no=8, type=4,VACANT</Slot>
</GATE>
<GATE NAME='1'>
<Slot sno='1'>slot no=1, type=4,VACANT</Slot>
<Slot sno='2'>slot no=2, type=2,VACANT</Slot>
<Slot sno='3'>slot no=3, type=4,VACANT</Slot>
<Slot sno='4'>slot no=4, type=2,VACANT</Slot>
</GATE>
</ITPL>:
I want to insert a new childnode under slot=5,which has its own
attributes.The code i have used is:
XmlDocument doc = new XmlDocument();
doc.Load ("c:\\gates.xml");
XmlNode Slot = doc.DocumentElement;
XmlNode vehicleNode = doc.CreateNode(XmlNodeType.Element, "vehicle",
string.Empty);
XmlAttribute attr = doc.CreateAttribute("slotno");
attr.InnerText = "5";
vehicleNode.Attributes.Append(attr);
XmlAttribute attr1 = doc.CreateAttribute("vno");
attr.InnerText = "KA12345";
vehicleNode.Attributes.Append(attr);
XmlAttribute attr2 = doc.CreateAttribute("vtype");
attr.InnerText = "honda";
vehicleNode.Attributes.Append(attr);
Slot.AppendChild(vehicleNode);
I want to know as how to query that particular slot before inserting the
new node?
--
Message posted via
http://www.dotnetmonster.com