문제

How can I parse a odata atom feed?

Notice: The xml data are already on my system. So I need a libary that takes a string or local file path.

Example:

<?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


........

Thank you:)

도움이 되었습니까?

해결책 2

You can refer generic XML parsing example in Java here

Basically:

File feed = new File("yourlocal/file/path/atom.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(feed);

Read more: http://javarevisited.blogspot.com/2011/12/parse-xml-file-in-java-example-tutorial.html#ixzz2OqpN0LFg

다른 팁

Take a look at odata4j. It has server / client support.

If you are using the .NET Framework, take a look at ODataLib. You can download it here as NuGet package: http://nuget.org/packages/Microsoft.Data.OData/5.3.0

or here from the WCF Data Services 5.3.0 RTM Tools Installer http://www.microsoft.com/en-us/download/details.aspx?id=35840

A small tutorial can be found here: http://blogs.msdn.com/b/astoriateam/archive/2011/10/14/introducing-the-odata-library.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top