mleopard
asked on
Get string into xmldatadocument
Ok here goes...
I have a web service that returns a custom xml string.
Something like this:
<NewDataSet>
<Success>True</Success>
<Error>No errors</Error>
<DateTime>2/28/2003 8:55:57AM</DateTime>
<Service>NewService</Servi ce>
<Method>NewMethod</Method>
<MiscData />
<xmlData>
<Data> <data1>1234</data1> <data2>875</data2> </Data>
</xmlData>
</NewDataSet>
Now what I would like to do is get this string back to my asp.net app and then grab the data2 value from the string. But in order to do this, I need to be able to load this string into an xmldatadocument. At least that is what I think but I'm not sure. Anyway, can someone post a code snippet in VB that shows how to load the string into the object and how to get the data2 value back out and put into a string? If this is not enough info, please let me know and I will provide any additional info.
I have a web service that returns a custom xml string.
Something like this:
<NewDataSet>
<Success>True</Success>
<Error>No errors</Error>
<DateTime>2/28/2003 8:55:57AM</DateTime>
<Service>NewService</Servi
<Method>NewMethod</Method>
<MiscData />
<xmlData>
<Data> <data1>1234</data1> <data2>875</data2> </Data>
</xmlData>
</NewDataSet>
Now what I would like to do is get this string back to my asp.net app and then grab the data2 value from the string. But in order to do this, I need to be able to load this string into an xmldatadocument. At least that is what I think but I'm not sure. Anyway, can someone post a code snippet in VB that shows how to load the string into the object and how to get the data2 value back out and put into a string? If this is not enough info, please let me know and I will provide any additional info.
ASKER
Thanks for the help. I guess I should have been a little more clear. My xml coming back from the web service is a string (defined in the web service method as a string) so it actually looks something like this:
myStr="<NewDataSet>
<Success>True</Success>
<Error>No errors</Error>
<DateTime>2/28/2003 8:55:57AM</DateTime>
<Service>NewService</Servi ce>
<Method>NewMethod</Method>
<MiscData />
<xmlData>
<Data> <data1>1234</data1> <data2>875</data2> </Data>
</xmlData>
</NewDataSet>"
So when I tried to load the xml string into the DOMDocument, it broke. So I assume that in the example, I would need to pass an xml stream? Sorry for my ignorance, I am still very new to this. Thanks
myStr="<NewDataSet>
<Success>True</Success>
<Error>No errors</Error>
<DateTime>2/28/2003 8:55:57AM</DateTime>
<Service>NewService</Servi
<Method>NewMethod</Method>
<MiscData />
<xmlData>
<Data> <data1>1234</data1> <data2>875</data2> </Data>
</xmlData>
</NewDataSet>"
So when I tried to load the xml string into the DOMDocument, it broke. So I assume that in the example, I would need to pass an xml stream? Sorry for my ignorance, I am still very new to this. Thanks
ASKER
BTW is the variable DataValue defined as a string?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No, DataValue is an IDOMNode object. That may be it
ASKER
Thanks for your help.
DOMDocument = new MSXML2.DOMDocument40
DOMDocument.loadxml(XMLStr
DataValue = DOMDocument.selectSingleNo
if not DataValue is nothing then
Result = DataValue.text
end if
XMLString is the xml and Result is the value of data2 if it exists.
I didn't bother putting in the error checking, but I think you can just look at DOMDocument.parseError.err