Home All Groups Group Topic Archive Search About

parsing an xml string into fields

Author
6 Mar 2006 8:27 PM
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?

Author
6 Mar 2006 8:55 PM
Chris
cj wrote:
> 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
Author
6 Mar 2006 8:57 PM
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
Author
7 Mar 2006 2:47 AM
vbnetdev
http://www.kjmsolutions.com/xmlsettings.htm

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



Show quote Hide quote
"cj" <cj@nospam.nospam> wrote in message
news:%23psCfxVQGHA.2496@TK2MSFTNGP11.phx.gbl...
> 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?
Author
7 Mar 2006 8:55 AM
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.
======================================================
Author
7 Mar 2006 2:16 PM
cj
What do you think of this method?
http://www.fawcette.com/vsm/2002_10/online/hottips/esposito2/


Yuan Ren[MSFT] wrote:
Show quoteHide quote
> 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.
> ======================================================
>
Author
8 Mar 2006 11:27 AM
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.
======================================================
Author
8 Mar 2006 1:56 PM
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.


Yuan Ren[MSFT] wrote:
Show quoteHide quote
> 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.
> ======================================================
>
Author
9 Mar 2006 12:01 PM
Yuan Ren[MSFT]
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!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support