PDA

View Full Version : XML within XML?


jpan
04-23-2004, 09:03 AM
Hi,

I have a dataset that receives data remotely through HTTP. The remote data is an XML such as


<RemoteData>
<DataXML>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;&lt;XMLMessage Version="1.8.1" MessageID="122" Description="CommandAck"&gt;
&lt;MessageID&gt;111&lt;/MessageID&gt;
&lt;/XMLMessage&gt;
</DataXML>
</RemoteData>


Now, is there a way I can load the XML in <DataXML> into another dataset? Or, is there a parser that I can use to explicitly input the XML string and then read the data (this approach is actually more useful for me, if available)??

Thank you!

antun
04-23-2004, 11:17 AM
The problem you have is that the stuff inside DataXML is not XML - it's text. If it were XML it would look like this:


<XMLMessage Version="1.8.1" ...


... instead of like this:


&lt;XMLMessage Version="1.8.1"...


You could write a method that took an XML-escaped string and converted it back to XML, then reset that into the method. I would declare a datapointer that points to ds_one:/RemoteData[1]/DataXML[1] and ondata reads the text() of that node, then parses through it (using the JavaScript String object methods to help you), replacing &lt; with <.

Or you could have a JSP (or other server side script) that your dataset hit that makes the request and converts it to XML for you, so by the time it gets to your Laszlo app, it is already XML.

As for copying one node from one dataset to another, see here:

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=222&highlight=copy+node

-Antun