How to put a xml into couchDB?

Your best bet is going to be to covert the XML into JSON before you send it to CouchDB. Of course, you could also not convert it and just store it in a JSON field. Your document might look something like this: { "_id": "...", "_rev": "...", "xml": "value1value2", ...some other fields... } You could also store the XML as an attachment: wiki.apache.org/couchdb/HTTP_Document_AP... That way you can make a call to dbName/documentID/storedData.

Xml or whatever, and get the file back with the proper XML Content-type It really depends on whether you want to get XML back, or whether you want to only work with the JSON after the conversion.

Your best bet is going to be to covert the XML into JSON before you send it to CouchDB. Of course, you could also not convert it and just store it in a JSON field. Your document might look something like this: { "_id": "...", "_rev": "...", "xml": "value1value2", ...some other fields... } You could also store the XML as an attachment: wiki.apache.org/couchdb/HTTP_Document_AP... That way you can make a call to /dbName/documentID/storedData.

Xml or whatever, and get the file back with the proper XML Content-type. It really depends on whether you want to get XML back, or whether you want to only work with the JSON after the conversion.

I want to get the json. So attachment is not suitable, maybe the best way is use a field of json to transfer xml to server, but it's inconvenient when my xml include so many '"' character. They must be escaped manually.

– user408393 Aug 10 '10 at 2:24 1 You shouldn't need to escape them manually. Just turn your XML into a string, which it already looks like it is, and then run json_encode(). It'll take care of all the escaping and formatting for you.

Also, you could always translate the XML into PHP objects (fairly simple operation), and then run it through json_encode() and store that in your document. – Sam Bisbee Aug 10 '10 at 17:22.

I found another way to do this, here is sample: 1. Create db curl -X PUT localhost:5984/bookstore 2. Create design document curl -X POST localhost:5984/bookstore/_bulk_docs -d @design.

Doc where design. Doc's content is: {"docs": { "_id": "_design/app", "updates": { "xml2json": " function (doc, req) { if(req.query. Doc == null) { return null, \"doc is null!

\\n\"; } var xmlDoc = req.query.doc. Replace(/^/, \"\"); var html = new XML(xmlDoc); if(doc==null) { doc = {}; doc. _id=html.BookList.BookData.

@isbn13.toString(); if(doc. _id==null||doc. _id==\"\") { doc.

_id=html.BookList.BookData. @isbn.toString(); } } if (doc. _id == null || doc.

_id == \"\") { return null, \"doc id is null! \\n\";; } doc. Title = html.BookList.BookData.Title.text(); doc.

Longtitle = html.BookList.BookData.TitleLong.text(); doc. Authors = html.BookList.BookData.AuthorsText.text(); doc. Publisher = html.BookList.BookData.PublisherText.text(); return doc, \"ok!

\\n\"; }" } } } test _update doc=$(cat isbndb. Sample); doc="$(perl -MURI::Escape -e 'print uri_escape($ARGV0);' "$doc")"; curl -X PUT localhost:5984/bookstore/_design/app/_update/xml2json/9781935182320? Doc="$doc" where isbndb.

Sample's content is: Mastering Perl Brian D. Foy Sebastopol, CA : O'Reilly Media, c2007.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions