Hey everyone,
I'm sure this is probably very basic but I could sure use some help.
I have a very small XML string which comes in to my application via an event.
I want to parse out the information from this string and store the bits of information in to variables.
The xml string is
<MSG><CMD>DATA</CMD><MEDIA>1</MEDIA><TASK>5680</TASK><ANI/><DNIS>6940</DNIS><DATA1>1111111</DATA1><DATA2/><DATA3/><DATA4/><DATA5/></MSG>
All I am trying to do right now is parse out the data within the DATA1 tags.
Any help would be greatly appreciated.
Thanks,
Bob
Parsing XML string... Please help.. :)
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
MykonineRank #2,671 · 521 pointsPosted Oct 15, 2005, 1:41 PM EDT
int endIndex = message.IndexOf("</Data1>"); //gets the index of the character just after the end of your data.
string myData = message.Substring(beginIndex, endIndex-beginIndex);
Bob Boursaw3 pointsPosted Oct 15, 2005, 2:09 PM EDT
I'm missing something here.
I understand the code you provided but how do you specify where the <DATA1> tag resides?
In a file out on disk, defined within a text string called inboundXML, etc?
In my case, I have a long XML string stored in a variable called inboundXML. How do I tell it to look within this string?