Reputation: 251
I have an XML document with certain elements in it. I need to add a new element, called "date", using JavaScript. I even have to retrieve the same. (Need to perform the MarkLogic transformations.)
CURL must not be used.
Thanks in advance.
Upvotes: 0
Views: 115
Reputation: 7335
By "xml sheet" I assume you mean an XML document.
Is your JavaScript running in the browser or in Node.js?
If you're executing JavaScript in Node.js and using MarkLogic 8.0, you can use the new Node.js API:
http://docs.marklogic.com/guide/node-dev
in particular, the patch request:
http://docs.marklogic.com/jsdoc/documents.html#patch
If you're executing JavaScript in the browser, you can use the REST API:
http://docs.marklogic.com/guide/rest-dev
and POST a patch request using the browser's XMLHttpRequest object:
http://docs.marklogic.com/REST/PATCH/v1/documents
As an alternative to the patch request, you can retrieve the XML document, modify it, and write it back to the server. You can find an answer about parsing XML in the browser here:
Cross-Browser Javascript XML Parsing
Hoping that helps
Upvotes: 2