Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

parsing an xml string into fields

2 views
Skip to first unread message

cj

unread,
Mar 6, 2006, 3:27:18 PM3/6/06
to
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?

Chris

unread,
Mar 6, 2006, 3:55:25 PM3/6/06
to

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

Chris

YYZ

unread,
Mar 6, 2006, 3:57:47 PM3/6/06
to
> 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

vbnetdev

unread,
Mar 6, 2006, 9:47:25 PM3/6/06
to
http://www.kjmsolutions.com/xmlsettings.htm

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"cj" <c...@nospam.nospam> wrote in message
news:%23psCfxV...@TK2MSFTNGP11.phx.gbl...

Yuan Ren[MSFT]

unread,
Mar 7, 2006, 3:55:05 AM3/7/06
to
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.
======================================================

cj

unread,
Mar 7, 2006, 9:16:31 AM3/7/06
to

Yuan Ren[MSFT]

unread,
Mar 8, 2006, 6:27:44 AM3/8/06
to
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

cj

unread,
Mar 8, 2006, 8:56:08 AM3/8/06
to
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.

Yuan Ren[MSFT]

unread,
Mar 9, 2006, 7:01:39 AM3/9/06
to
Hi,

Thanks for your reply!

If you want to use the XmlTextReader class, the following article
demonstrates how to do this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconReadingXMLWithXmlReader.asp

Actually, the ReadInnerXml method is appropriated. Hope this will be useful!

0 new messages