1

如何解析 odata atom 提要?

注意: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


........

谢谢:)

4

3 回答 3

1

看看odata4j。它具有服务器/客户端支持。

于 2013-03-28T16:11:01.787 回答
0

您可以在此处参考 Java 中的通用 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

于 2013-03-28T16:05:51.260 回答
0

如果您使用的是 .NET Framework,请查看 ODataLib。你可以在这里下载它作为 NuGet 包: http: //nuget.org/packages/Microsoft.Data.OData/5.3.0

或从 WCF 数据服务 5.3.0 RTM 工具安装程序 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

于 2013-04-01T21:38:05.997 回答