2

I need to get the XPages Extension Library DataGrid (<xe:djxDataGrid>) content out as XML.

In my client side JavaScipt I'm looping thru all rows, getting values and building my XML using dojox.data.XmlStore.

The problem is that when I try to save the XML, it POSTs as many times as I've added tags and each POST contains <?xml version="1.0"?> and one tag.

Here is a simple sample code trying to create a simple XML file:

var xml_store = new dojox.data.XmlStore({url: "backend_save_to_file.xsp", rootItem: "tests"});
xml_store.newItem({tagName: "test1"}, "tests");
xml_store.newItem({tagName: "test2"}, "tests");
xml_store.save();

Running this JavaScript causes two HTTP POSTs to backend_save_to_file.xsp with these contents:

  1. <?xml version="1.0"?><test1/>
  2. <?xml version="1.0"?><test2/>

I would expect one POST containing:

<?xml version="1.0"?><tests><test1/><test2/></tests>

What am I doing wrong?

EDIT: I could not get this to work so I'm trying to just build the XML in a string. I'm using dojox.html.entities.encode to escape the XML values but looks like this is not the correct way. For example character รค is converted to &auml;. IE will not recognize a file containing &auml; as XML (I've tried different encodings in xml tag). If I use &#228; instead IE will recognize it as XML. How do I escape XML in dojo?

EDIT2: I ended up using this simple encoding:

how to escape xml entities in javascript?

But it does not remove the characters that are illegal in XML. Of course there are code snippets that remove them too but I would be surprised if there is no utility in Dojo to do it.

thanks,

  • Panu
Community
  • 1
  • 1
Panu Haaramo
  • 2,932
  • 19
  • 41

0 Answers0