<InputParameters>
<Textbox>
<Text>ABCD</Text>
<Text>EFGH</Text>
<Text>HIJK</Text>
</Textbox>
</InputParameters>
假設我必須將這個xml文件數據添加到arangodb中。如何能夠這樣做?如何將xml文件數據添加到ArangoDb?
<InputParameters>
<Textbox>
<Text>ABCD</Text>
<Text>EFGH</Text>
<Text>HIJK</Text>
</Textbox>
</InputParameters>
假設我必須將這個xml文件數據添加到arangodb中。如何能夠這樣做?如何將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的應用程序更多的例子git repository。
有兩個適當的解決方案。 一種是將整個XML放入文檔的屬性中。這對於在xml的有效負載上執行AQL查詢可能會有所幫助。
另一種可能的方法是使用jsonml將您的xml轉換爲結構化的json文檔並將它們存儲在using their java library中。儘管如此,我不知道如何在複雜的XML上進行擴展。
然後,您可以創建AQL查詢以處理該集合,而FILTER
可以創建源XML的屬性。
我們在[ArangoDB Cookbook](https://docs.arangodb.com/cookbook/JavaDriverXmlData.html)中加入了詳細描述, – dothebart