如何解析odata原子进料?
注意:xml数据已经在我的系统上。所以我需要一个带字符串或本地文件路径的库。
示例:
<?xml version="1.0" encoding="utf-8"?><feed xml:base="http://10.0.2.2/dataservice/data.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><id>http://10.0.2.2/dataservice/data.svc/Areas/</id><title type="text">Areas</title><updated>2013-03-28T14:45:13Z</updated><link rel="self" title="Areas" href="Areas" /><entry><id>http://10.0.2.2/dataservice/data.svc/Areas('filestore')</id><category term="Dms.Data.Services.Context.Entities.DmsArchiveArea" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link rel="edit" title="DmsArchiveArea" href="Areas('filestore')" /><title /><updated>2013-03-28T14:45:13Z</updated><author><name /></author><content type="application/xml"><m:properties><d:Id>filestore</d:Id><d:Name>filestore</d:Name><d:Reche m:type="Edm.Boolean">true</d:Reche><d:Scann m:type="Edm.Boolean">true</d:Scann><d:Indiz m:type="Edm.Boolean">true</d:Indiz><d:Datei m:type="Edm.Boolean">true</d:Datei><d:Revis m:type="Edm.Boolean">true</d:Revis><d:Speich m:type="Edm.Boolean">true</d:Speich><d:Druck m:type="Edm.Boolean">true</d:Druck><d:Mail m:type="Edm.Boolean">true</d:Mail><d:Archiv m:type="Edm.Boolean">true</d:Archiv><d:Attrae m:type="Edm.Boolean">true</d:Attrae><d:Annoarch m:type="Edm.Boolean">true</d:Annoarch><d:Annorech m:type="Edm.Boolean">true</d:Annorech><d:Annorevi m:type="Edm.Boolean">true</d:Annorevi><d:ReviView m:type="Edm.Boolean">true</d:ReviView><d:ReviAend m:type="Edm.Boolean">true</d:ReviAend><d:WeichAttribAend m:type="Edm.Boolean">true</d:WeichAttribAend><d:IntervallEinstellBar m:type="Edm.Boolean">true</d:IntervallEinstellBar><d:SeitenKopieren m:type="Edm.Boolean">true</d:SeitenKopieren><d:SeitenAend m:type="Edm.Boolean">true</d:SeitenAend><d:DokLoeschen m:type="Edm.Boolean">true</d:DokLoeschen></m:properties></content></entry
........
谢谢:)
答案 0 :(得分:1)
看看odata4j。它有服务器/客户端支持。
答案 1 :(得分:0)
您可以在Java here
中引用通用XML解析示例基本上:
File feed = new File("yourlocal/file/path/atom.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(feed);
了解详情:http://javarevisited.blogspot.com/2011/12/parse-xml-file-in-java-example-tutorial.html#ixzz2OqpN0LFg
答案 2 :(得分:0)
如果您使用的是.NET Framework,请查看ODataLib。您可以在此处下载NuGet包:http://nuget.org/packages/Microsoft.Data.OData/5.3.0
或来自WCF Data Services 5.3.0 RTM Tools安装程序 http://www.microsoft.com/en-us/download/details.aspx?id=35840
可在此处找到一个小教程:http://blogs.msdn.com/b/astoriateam/archive/2011/10/14/introducing-the-odata-library.aspx