Bonjour,

Je n'arrive pas a parser un fichier de type rss1.0 pour un fichier rss 2.0, y a pas de problème. Si je fait test("rss/channel/item/title") pour un fichier rss2.0 ca marche mais j'ai aucun résultat si je fais test("rdf:RDF/channel/item/title")

Merci de votre aide

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
 
	public static void test(InputStream in, String expression)
			throws ParserConfigurationException, XPathExpressionException,
			org.xml.sax.SAXException, java.io.IOException {
 
		DocumentBuilder parser = DocumentBuilderFactory.newInstance()
				.newDocumentBuilder();
		Document doc = parser.parse(in);
 
		XPath xpath = XPathFactory.newInstance().newXPath();
 
		NodeList nodes = (NodeList) xpath.evaluate(expression, doc,
				XPathConstants.NODESET);
 
		for (int i = 0; i < nodes.getLength(); i++) {
			System.out.println((nodes.item(i).getTextContent()));
		}
	}
Le fichier rss 1.0 à parser :
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
<?xml version="1.0"?>
 
<rdf:RDF 
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
>
 
  <channel rdf:about="http://www.xml.com/xml/news.rss">
    <title>XML.com</title>
    <link>http://xml.com/pub</link>
    <description>
      XML.com features a rich mix of information and services 
      for the XML community.
    </description>
 
    <image rdf:resource="http://xml.com/universal/images/xml_tiny
.gif" />
 
    <items>
      <rdf:Seq>
        <rdf:li resource="http://xml.com/pub/2000/08/09/xslt/xslt
.html" />
        <rdf:li resource="http://xml.com/pub/2000/08/09/rdfdb/ind
ex.html" />
      </rdf:Seq>
    </items>
 
    <textinput rdf:resource="http://search.xml.com" />
 
  </channel>
 
  <image rdf:about="http://xml.com/universal/images/xml_tiny.gif"
>
    <title>XML.com</title>
    <link>http://www.xml.com</link>
    <url>http://xml.com/universal/images/xml_tiny.gif</url>
  </image>
 
 
  <item rdf:about="http://xml.com/pub/2000/08/09/xslt/xslt.html">
    <title>Processing Inclusions with XSLT</title>
    <link>http://xml.com/pub/2000/08/09/xslt/xslt.html</link>
    <description>
     Processing document inclusions with general XML tools can be
 
     problematic. This article proposes a way of preserving inclu
sion 
     information through SAX-based processing.
    </description>
  </item>
 
  <item rdf:about="http://xml.com/pub/2000/08/09/rdfdb/index.html
">
 
    <title>Putting RDF to Work</title>
    <link>http://xml.com/pub/2000/08/09/rdfdb/index.html</link>
    <description>
     Tool and API support for the Resource Description Framework 
     is slowly coming of age. Edd Dumbill takes a look at RDFDB, 
     one of the most exciting new RDF toolkits.
    </description>
  </item>
 
  <textinput rdf:about="http://search.xml.com">
    <title>Search XML.com</title>
 
    <description>Search XML.com's XML collection</description>
    <name>s</name>
    <link>http://search.xml.com</link>
  </textinput>
 
</rdf:RDF>