xml file using vb.net

I would like to remove the folowing items form the attached xml file programmatically using vb.net. Any help here would be greatly appreciated.

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<field name="Send"/>
<ids original="C0D4AFCC3BAC5AC8060BBF8AD9CA33F9" modified="73A35486E49D844DAAD9BB91815D72E2"/>
<f href="http://www.eriskservices.com/Forms/BAMApp0408Test.pdf"/>
</xfdf>

4-26-2010-3-16-06-PM.xml
LVL 2
E-RiskAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Meir RivkinFull stack Software EngineerCommented:
here's the code and output xml attached:
Dim xml As String = "c:\temp\14-26-2010-3-16-06-PM.xml"
Dim root As XElement = XElement.Load(xml)
Dim fields As XElement = root.Elements().First()
Dim xe As XElement = fields.Elements().Where(Function(n) n.Attribute("name").Value = "Send").FirstOrDefault()
xe.Remove()
fields.Save("c:\temp\output.xml")

Open in new window

output.xml.txt
0
jeebukarthikeyanCommented:
0
Meir RivkinFull stack Software EngineerCommented:
@E-Risk

the code i've posted is applied to .net 3.5, if u use earlier .net versions let me know and i'll post you a new snippet.

cheers
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

E-RiskAuthor Commented:
sedgwick,
Yes I am actually using .net 2. How does this differ? Thanks.
0
Meir RivkinFull stack Software EngineerCommented:
here's it in .net 2.0:
Dim xml As String = "c:\temp\4-26-2010-3-16-06-PM.xml"
        Dim xdoc As New XmlDocument()
        xdoc.Load(xml)

        Dim node As XmlNode = xdoc.DocumentElement.ChildNodes(0)
        Dim xnode As XmlNode = node.CloneNode(True)
        xdoc.RemoveChild(xdoc.ChildNodes(1))
        xdoc.AppendChild(xnode)
        Dim root As XmlElement = xdoc.DocumentElement
        For Each item As XmlNode In root.ChildNodes
            If item.Attributes("name").Value = "Send" Then
                root.RemoveChild(item)
                Exit For
            End If
        Next
        xdoc.Save("c:\temp\output.xml")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Meir RivkinFull stack Software EngineerCommented:
u need to add: Imports System.Xml
0
E-RiskAuthor Commented:
Awesome!! I wish I could give 1000 points. Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.