<InputParameters>
<Textbox>
<Text>ABCD</Text>
<Text>EFGH</Text>
<Text>HIJK</Text>
</Textbox>
</InputParameters>
假设我必须将这个 xml 文件数据添加到 arangodb 中。如何才能做到这一点?
最佳答案
自版本 2.7.1 起,aragodb-java-driver 支持写入 (createDocumentRaw(...)) 和读取 (getDocumentRaw(...)) 原始字符串。
例子:
arangoDriver.createDocumentRaw("testCollection", "{\"test\":123}",
true, false);
与 JsonML您可以将 XML 字符串转换为 JSON 字符串并将其存储到 ArangoDB 中:
// writing
String xml = "<recipe name=\"bread\" prep_time=\"5 mins\"</recipe> ";
JSONObject jsonObject = JSONML.toJSONObject(string);
DocumentEntity<String> entity = arangoDriver.createDocumentRaw(
"testCollection", jsonObject.toString(), true, false);
String documentHandle = entity.getDocumentHandle();
// reading
String json = arangoDriver.getDocumentRaw(documentHandle, null, null);
JSONObject jsonObject2 = new JSONObject(str);
String xml2 = JSONML.toString(jsonObject2));
您可以在 arangodb-java-driver git repository 中找到更多示例.
关于java - 如何将xml文件数据添加到ArangoDb中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34747391/