parsing an xml string into fields

C

cj

I'm getting a small xml file as on big string and need to parse it into
it's fields for use. Can anyone point me to a nifty way to do this in .net?
 
C

Chris

cj said:
I'm getting a small xml file as on big string and need to parse it into
it's fields for use. Can anyone point me to a nifty way to do this in
.net?

Take a look at the xmldocument class. There is a method there that load
from a string.

Chris
 
Y

YYZ

I'm getting a small xml file as on big string and need to parse it into
it's fields for use. Can anyone point me to a nifty way to do this in .net?

dim oDom as new XMLDocument

oDom.LoadXML(sXml)

....is that what you were looking for?

Matt
 
Y

Yuan Ren[MSFT]

Hi,

Thanks for posting!

From your description, my understanding is that you want to read a XML
format string and obtain some values in it. If I have misunderstood
anything, please let me know.

As Matt mentioned, the XmlDocument.LoadXml method is appropriated for the
current issue. The following article from MSDN demonstrates how to approach
this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemxmlxmldocumentclassloadxmltopic.asp

Thanks for your understanding!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
updated on February 14, 2006. Please complete a re-registration process
by entering the secure code mmpng06 when prompted. Once you have
entered the secure code mmpng06, you will be able to update your profile
and access the partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
Y

Yuan Ren[MSFT]

Hi,

Thanks for your reply!

Using the XmlReader class is also appropriated. Just for your reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconreadingxmlwithxmlreader.asp

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
updated on February 14, 2006. Please complete a re-registration process
by entering the secure code mmpng06 when prompted. Once you have
entered the secure code mmpng06, you will be able to update your profile
and access the partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 
C

cj

I went with Matt's and your way after all. I couldn't figure out how to
retrieve the values from the XmlTextReader.

Here's what I have now:

Dim doc As New XmlDocument
doc.LoadXml(xmlReply)

Dim actNbr As XmlNodeList = doc.GetElementsByTagName("account_number")
Dim replyCode As XmlNodeList = doc.GetElementsByTagName("reply_code")

MessageBox.Show("Account: " & actNbr(0).InnerText)
MessageBox.Show("Reply code: " & replyCode(0).InnerText)

This works fine but I want to learn and am always open to suggestions if
anyone has any.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top