Deleting All nodes in XML after Particular node



Hi I have an XML as follows.



<?xml version="1.0" encoding="utf-8"?>
-<Master>
<UserDetails>
<UserName>Michael</UserName>
<Password>Password</Password>
</UserDetails>
<Height>155</Height>
<Weight>150lb</Weight>
<OtherDetails>
<Phone>987654327</Phone>
<Email>mich.int@ymail.com</Email>
</UserDetails>
<company>155</company>
<address>155 beecroft</address>
</Master>


My requirement is to remove all nodes below HEIGHT <Height> node. No matter how many nodes are there after HEIGHT <Height> should be removed from XML My final output should be.



<?xml version="1.0" encoding="utf-8"?>
-<Master>
<UserDetails>
<UserName>Michael</UserName>
<Password>Password</Password>
</UserDetails>
<Height>155</Height>
</Master>


Please let me know how i can do it in VB.NET.


No comments:

Post a Comment