Note that there are some explanatory texts on larger screens.

plurals
  1. POparsing XML file with jdom+eclipse
    text
    copied!<p>I have a problem while parsing an xml file. this is a portion of this file:</p> <pre><code>&lt;item&gt; &lt;title&gt;Andrew of Auditory Implant&lt;/title&gt; &lt;link&gt;http://www.flickr.com/photos/mike-burns/65651809/&lt;/link&gt; &lt;description&gt;&amp;lt;p&amp;gt;&amp;lt;a href="http://www.flickr.com/people/mike-burns/"&amp;gt;Mike Burns&amp;lt;/a&amp;gt; a posté une photoÂ*:&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&amp;lt;a href="http://www.flickr.com/photos/mike-burns/65651809/" title="Andrew of Auditory Implant"&amp;gt;&amp;lt;img src="http://farm1.staticflickr.com/31/65651809_0935d9acbf_m.jpg" width="180" height="240" alt="Andrew of Auditory Implant" /&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;November 20th, 2005 @ Middle East Upstairs.&amp;lt;/p&amp;gt;&lt;/description&gt; &lt;pubDate&gt;Mon, 21 Nov 2005 14:25:17 -0800&lt;/pubDate&gt; &lt;dc:date.Taken&gt;2005-11-20T22:24:30-08:00&lt;/dc:date.Taken&gt; &lt;author flickr:profile="http://www.flickr.com/people/mike-burns/"&gt;nobody@flickr.com (Mike Burns)&lt;/author&gt; &lt;guid isPermaLink="false"&gt;tag:flickr.com,2004:/photo/65651809&lt;/guid&gt; &lt;media:content url="http://farm1.staticflickr.com/31/65651809_0935d9acbf_b.jpg" type="image/jpeg" height="1024" width="766" /&gt; &lt;media:title&gt;Andrew of Auditory Implant&lt;/media:title&gt; &lt;media:description type="html"&gt;&amp;lt;p&amp;gt;November 20th, 2005 @ Middle East Upstairs.&amp;lt;/p&amp;gt;&lt;/media:description&gt; &lt;media:thumbnail url="http://farm1.staticflickr.com/31/65651809_0935d9acbf_s.jpg" height="75" width="75" /&gt; &lt;media:credit role="photographer"&gt;Mike Burns&lt;/media:credit&gt; &lt;media:category scheme="urn:flickr:tags"&gt;upcoming40467 auditoryimplant middleeastupstairs upcomingorg upcomingevent&lt;/media:category&gt; &lt;creativeCommons:license&gt;http://creativecommons.org/licenses/by-sa/2.0/deed.fr&lt;/creativeCommons:license&gt; &lt;/item&gt; </code></pre> <p>the problem is in this line:</p> <pre><code>&lt;media:category scheme="urn:flickr:tags"&gt;upcoming40467 auditoryimplant middleeastupstairs upcomingorg upcomingevent&lt;/media:category&gt; </code></pre> <p>this is my java code:</p> <pre><code>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")); ..... </code></pre> <p>it works for title and description but not for media:category. when I do:</p> <pre><code>System.out.println(courant.getChild("media:category")); </code></pre> <p>I found:</p> <blockquote> <p>null Could anyone help me?</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload