Search code examples
javascriptajaxxmlexist-db

How to add an XML file to eXist db form java script?


I'm new to eXist db.I can able to retrieve an xml file from db but how can i store my own XML file into a collection(collection name:test) using AJAX javaScript?

My Sample XML file looks like this

<?xml version='1.0' encoding='utf-8'?> 
 <Configuration>
   <IP>120.6.45.35</IP>
   <Communitystring>public</Communitystring>
   <Template>generic</Template>
 </Configuration>

Please anyone help me?

Please answer my question.

Thanks in advance.


Solution

  • You can use eXist RESTful API to add a document to the database. You'll have to issue an HTTP PUT request and send the document as message body. You need to specify content type as application/xml The address should be:

    (eXist_host):(port)/exist/rest/(path_to_target_collection)/(file_name)

    You can do it in JQuery AJAX or using a plain XmlHttpRequest.

    See the eXist developer guide for more information.