Hi Board.

I face the following challenge:

On a workorder object I retrieves a string which is actually a XML
document where "<" is replaced by "&lt;".
In my form I converts this to a DOM object (I am aware that there are
differences in how the various browsers implement nodesets, and I have
coded that into account. But it does not really mather, because all
users are using the same browser because they are using a coorporate
standard hardware setup, with a cooporate standard image on top), and
addresses and retracts the needed information (in fact I only needs a
value from one single node in the form).

When - however - It comes to flowdata, I needs to add a node to a
parent node.

I needs to do the following:


- Convert the string to XML object/nodeset
- Add a child node to a specific node
- Convert the intire nodeset back to a string and replace "<" with
"&lt;" again.


In flowdata I have the opportunity to use JAVA which I think is more
robust when it comes to working with XML.

So the first part of converting to a nodeset I solved this way:


Code:
--------------------
function String2XML(xmlStr)
{
var nodeSet = new Packages.com.novell.xml.xpath.NodeSet();
var factory = new Packages.com.novell.xml.parser.XMLParserFactory.ne wParser();
var stringreader = Packages.java.io.StringReader;

var strinput = new stringreader(xmlStr);
var doc = factory.parse(strinput);
nodeSet.add(doc);
return nodeSet;
}
--------------------


This is the string which I needs to convert:

Code:
--------------------
&lt;data>&lt;startdate>2012-08-15T00:00:00.000+02:00&lt;/startdate>&lt;enddate>2012-10-27T00:00:00.000+02:00&lt;/enddate>&lt;udlaaner>24122&lt;/udlaaner>&lt;modtager>24222&lt;/modtager>&lt;initiator>cn=ADMKEVRAS,ou=SA,o=Data&l t;/initiator>&lt;desc>&lt;value>test 11&lt;/value>&lt;/desc>&lt;A1>cn=Souschef,ou=Fakta,ou=Stillinger,ou= Groups,o=Data&lt;/A1>&lt;/data>
--------------------


When I replaces the "&lt;" with "<", it looks like this:


Code:
--------------------
<data>
<startdate>2012-08-15T00:00:00.000+02:00</startdate>
<enddate>2012-10-27T00:00:00.000+02:00</enddate>
<udlaaner>24122</udlaaner>
<modtager>24222</modtager>
<initiator>cn=ADMKEVRAS,ou=SA,o=Data</initiator>
<desc>
<value>test 11</value>
</desc>
<A1>cn=Souschef,ou=Fakta,ou=Stillinger,ou=Groups,o =Data</A1>
</data>
--------------------


So this:


Code:
--------------------
var XMLStr = '&lt;data>&lt;startdate>2012-08-15T00:00:00.000+02:00&lt;/startdate>&lt;enddate>2012-10-27T00:00:00.000+02:00&lt;/enddate>&lt;udlaaner>24122&lt;/udlaaner>&lt;modtager>24222&lt;/modtager>&lt;initiator>cn=ADMKEVRAS,ou=SA,o=Data&l t;/initiator>&lt;desc>&lt;value>test 11&lt;/value>&lt;/desc>&lt;A1>cn=Souschef,ou=Fakta,ou=Stillinger,ou= Groups,o=Data&lt;/A1>&lt;/data>';

var NodeSet = String2XML(XMLStr);
--------------------


Gives me the nodeset.

So now I needs to add a *<value />* more to the *<desc />* node, and
then convert the intire nodeset back to a string and replace "<" with
"&lt;".

My JAVA skills comes to short here and I thinks to have read somewhere
that I can take advantage of the built-in Novell Libraries for
ECMAScript for working with XML documents instead.
Can anyone help me here?
Please have in mind that this is till in flowdata.

Thanks!


--
kkrasmussen
------------------------------------------------------------------------
kkrasmussen's Profile: http://forums.novell.com/member.php?userid=20966
View this thread: http://forums.novell.com/showthread.php?t=457636