HI..In this article we will see about XML. Here we can find and remove the particular node in xml,I hope this one will be useful to delete and replace particular node in xml.
For an example xml structure should looks like below
<picture>
<image>
<id>1</id>
<name>raju</name
</image>
<image>
<id>2</id>
<name>karthi</name
</image>
<image>
<id>3</id>
<name>siva</name
</image>
Here if u want to delete the node ‘2’ ,For that you have to write the code like below…. Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim id As String
xmlpath = Server.MapPath("~/imagefile.xml")
id = “2”
Dim xmldoc As New XmlDocument
xmldoc.Load(xmlpath)
Dim child As XmlNode = xmldoc.SelectSingleNode("picture/image[ID='" & id & "']")
xmldoc.DocumentElement.RemoveChild(child)
xmldoc.Save(xmlpath)
End SUb
After remove the node your xmlshould like below…
<picture>
<image>
<id>1</id>
<name>raju</name
</image>
<image>
<id>3</id>
<name>siva</name
</image>
I hope this one helpful to you…post your valuable comments here..
0 comments:
Post a Comment