如何将 xml 文件数据添加到 ArangoDb 中?
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 to translate your xml into structured json documents, and store them using their java library。我不知道这在像 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 repository.
中找到更多示例
<InputParameters>
<Textbox>
<Text>ABCD</Text>
<Text>EFGH</Text>
<Text>HIJK</Text>
</Textbox>
</InputParameters>
假设我必须将此 xml 文件数据添加到 arangodb 中。怎样才能做到这一点?
有两个正确的解决方案。 一种是把整个XML放到一个文档的一个属性中。这在术语上可能不利于对 xml.
的有效负载进行 AQL 查询另一种可能的方法是使用 jsonml to translate your xml into structured json documents, and store them using their java library。我不知道这在像 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 repository.
中找到更多示例