|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Parsing XML stringsHi,
I have XML data in a string format and want to extract the content and parse it. Can anyone suggest any methods/techniques/ways to do this please? Any comments/suggestions/code-snippets much appreciated. Al The XML newbie <almu***@altavista.com> schrieb:
> I have XML data in a string format and want to extract the content You could load the string into an 'XmlDocument' object and use its methods > and parse it. Can anyone suggest any methods/techniques/ways to do this > please? to locate the content. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> As Herfried suggests, the DOM can be used and I would guess recommended
for a very simple XML file. But I have recently been impressed with the power of .NET XMLSerialization. Even for a simple XML file, it doesn't take very long to set up the class(s) and properties, and to read it in or write it out only takes two method calls. Just did that. Here's what I did to retrieve the account_number and
reply_code fields from the xml string. Hope it helps. Dim doc As New XmlDocument doc.LoadXml(xmlString) 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) almu***@altavista.com wrote: Show quoteHide quote > Hi, > > I have XML data in a string format and want to extract the content > and parse it. Can anyone suggest any methods/techniques/ways to do this > please? > > Any comments/suggestions/code-snippets much appreciated. > > Al > The XML newbie >
VB.Net 2005 Treeview example required
WebBrowser Handles keyword. FileStream is adding extra characters Optimizing Repeated PictureBox.Paints padding text field with blank in MS Access vs OLEDB Jet 4.0 Getting icon from form in dynamically loaded DLL Browsers Threading make computer slow Block Step Into Debugging for a function |
|||||||||||||||||||||||