Je veux parser cette partie du fichier XML:
J'ai un problème à ce niveau:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 <item> <title>Andrew of Auditory Implant</title> <link>http://www.flickr.com/photos/mike-burns/65651809/</link> <description><p><a href="http://www.flickr.com/people/mike-burns/">Mike Burns</a> a posté une photoÂ*:</p> <p><a href="http://www.flickr.com/photos/mike-burns/65651809/" title="Andrew of Auditory Implant"><img src="http://farm1.staticflickr.com/31/65651809_0935d9acbf_m.jpg" width="180" height="240" alt="Andrew of Auditory Implant" /></a></p> <p>November 20th, 2005 @ Middle East Upstairs.</p></description> <pubDate>Mon, 21 Nov 2005 14:25:17 -0800</pubDate> <dc:date.Taken>2005-11-20T22:24:30-08:00</dc:date.Taken> <author flickr:profile="http://www.flickr.com/people/mike-burns/">nobody@flickr.com (Mike Burns)</author> <guid isPermaLink="false">tag:flickr.com,2004:/photo/65651809</guid> <media:content url="http://farm1.staticflickr.com/31/65651809_0935d9acbf_b.jpg" type="image/jpeg" height="1024" width="766" /> <media:title>Andrew of Auditory Implant</media:title> <media:description type="html"><p>November 20th, 2005 @ Middle East Upstairs.</p></media:description> <media:thumbnail url="http://farm1.staticflickr.com/31/65651809_0935d9acbf_s.jpg" height="75" width="75" /> <media:credit role="photographer">Mike Burns</media:credit> <media:category scheme="urn:flickr:tags">upcoming40467 auditoryimplant middleeastupstairs upcomingorg upcomingevent</media:category> <creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.0/deed.fr</creativeCommons:license> </item>
Voici un bout de mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part <media:category scheme="urn:flickr:tags">upcoming40467 auditoryimplant middleeastupstairs upcomingorg upcomingevent</media:category>
ça marche pour title et description mais pour media:category, il me rend null:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 SAXBuilder sxb = new SAXBuilder(); try { //On crée un nouveau document JDOM avec en argument le fichier XML document = sxb.build(new File(fileName)); racine = document.getRootElement().getChild("channel"); System.out.println( "racine"+racine); List listPhotos = racine.getChildren("item"); System.out.println (listPhotos.size()); //On crée un Iterator sur notre liste Iterator j = listPhotos.iterator(); while(j.hasNext()) { Element courant = (Element)j.next(); System.out.println("courant:="+courant); String Title = courant.getChild("title").getValue(); System.out.println("Title:="+Title); String description= courant.getChild("description").getValue(); System.out.println("description:="+description); //String tags= courant.getChild("media:category").getValue(); //System.out.println("media:category:="+tags); System.out.println(courant.getChild("media:category"));
pour:null
Pouvez-vous m'aider?
Code : Sélectionner tout - Visualiser dans une fenêtre à part System.out.println(courant.getChild("media:category"));
Partager