0

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.

Dave Cassel
  • 8,352
  • 20
  • 38
S K padala
  • 251
  • 2
  • 3
  • 16
  • Can you please add more information to your question. Can you share the make up of the "xml sheet". And what you mean by using java script? Marklogic 8 has server side javascript is that what you are talking about or do you mean client side? And what do you mean by retrieve the same? does this mean you need to retrieve the update xml document? – Tyler Replogle Mar 20 '15 at 18:08

1 Answers1

2

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

Community
  • 1
  • 1
ehennum
  • 7,295
  • 13
  • 9