[英]How to add xml file data into ArangoDb?
<InputParameters>
<Textbox>
<Text>ABCD</Text>
<Text>EFGH</Text>
<Text>HIJK</Text>
</Textbox>
</InputParameters>
假设我必须将此xml文件数据添加到arangodb中。 一个人该怎么做呢?
有两种适当的解决方案。 一种是将整个XML放入文档的属性中。 这样一来,这可能不利于对xml的有效负载执行AQL查询。
另一种可能的方法是使用jsonml将xml转换为结构化的json文档,并使用其java库进行存储。 我不知道这在SOAP等复杂XML上的扩展能力如何。
然后,您可以创建AQL查询以对该集合进行操作,并创建FILTER
以获取源XML的属性。
从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 存储库中找到更多示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.