Parse string with xml data in

Dear All,

I am completely new to XML, and I would appreciate if you help me with the code in VB.NET to parse the string in the attachment containing XML data to get the values of the elements “f:cn” and “e:attachment”.

Please find the attachment containing the xml data. I neeed to pass it as a streing and not as a xml file.

I am in a pressing deadline to deliver, will really appreciate if you help me out.


Is the method you can use to load the XML string.

In regards to those elements, they exist on a namespace that I think you will have to register with the parser.

i use the loadxml method and also preserviing whitepsace.

after that how do i retreieve the values of nodes “f:cn” and “e:attachmentfile”??

Dim XMLDoc As New XmlDocument()


Dim nodeList As XmlNodeList = XMLDoc.GetElementsByTagName(“f:cn”)
Dim i As Integer

For i = 0 To nodeList.Count - 1
Next i

If the above doesn’t work, try looking into this:

i tried the code given by you.

it displays the name of the node “f:cn” but not the value of the “f:cn” node.

also how can i modify the code to include the node"e:attachmentfilename"

thanks so much

Change GetElementsByTagName(“f:cn”) to


To get the contents try:

For i = 0 To nodeList.Count - 1
Next i

can you combine these two getelementtagnanmes into one for loop?

From the example you gave there’s no point in using a loop.

Console.WriteLine("f:cn Value: " + XMLDoc.GetElementsByTagName(“f:cn”).item(0).innerXML)

Console.WriteLine("e:attachmentfilename Value: " + XMLDoc.GetElementsByTagName(“e:attachmentfilename”).item(0).innerXML)