Re: Replacing XML Elements programmatically with either VB.Net or C#
- From: "Saurabh" <online.skolte@xxxxxxxxx>
- Date: 28 Sep 2006 00:25:14 -0700
This code is for retrieval:
XmlDocument xdoc = new XmlDocument();
string strXML = "<Root_Element><Topic
index=\"1\"><Sub_Topic><Notes>";
strXML += "</Notes><Notes></Notes></Sub_Topic></Topic>";
strXML += "<Topic index=\"2\"><Sub_Topic><Notes></Notes>";
strXML += "<Notes></Notes><Notes></Notes></Sub_Topic><Sub_Topic>";
strXML += "<Notes></Notes></Sub_Topic></Topic><Topic index=\"3\">";
strXML +=
"<Sub_Topic><Notes></Notes></Sub_Topic></Topic></Root_Element>";
xdoc.LoadXml(strXML);
while(xdoc.HasChildNodes)
{
for(int i = 0; i < xdoc.SelectNodes("/Root_Element/").Count; i++)
{
if(xdoc.GetElementsByTagName("Topic")[i].Attributes[0].Value.ToString().Equals("2"))
{
/* Now Replace the childNodes */
}
}
}
.
- References:
- Replacing XML Elements programmatically with either VB.Net or C#
- From: James Fifth
- Replacing XML Elements programmatically with either VB.Net or C#
- Prev by Date: Windows Service is locking xml file - Need help
- Next by Date: Re: Events unsubscribing and resource leaks?
- Previous by thread: Re: Replacing XML Elements programmatically with either VB.Net or C#
- Next by thread: MDI one Child instance.
- Index(es):