Parsing atom:link field in XML with XPath from Play.libs?

Note that XPath expression are relative to a context, in your case the document node. Your expression selects all elements that are direct children of the document (and, of course, there aren't any). You need to either specify the complete path to the desired atom link element, or use some predicate that uniquely identifies it os:servers/os:server1/atom:linkrel='self' would select an element with rel=self contained in the first element UPDATE: If you have the no namespace problem xmlDoc.getRootElement.getNamespaceURI() should return null.In that case, it is easy to work around using the test code found in the bug report above.

Note that XPath expression are relative to a context, in your case the document node. Your expression selects all elements that are direct children of the document (and, of course, there aren't any). You need to either specify the complete path to the desired atom link element, or use some predicate that uniquely identifies it."/os:servers/os:server1/atom:linkrel='self'" would select an element with rel=self contained in the first element.

UPDATE: If you have the no namespace problem, xmlDoc.getRootElement.getNamespaceURI() should return null. In that case, it is easy to work around using the test code found in the bug report above.

Thank you for your response. But I get that error : Cannot resolve namespace prefix 'os'. Looks like I have to create a new namespace.

– Yoann Couble Aug 5 at 13:48 yes, you need to add a binding os -> docs.openstack. Org/compute/api/v1.1 – forty-two Aug 5 at 13:55 as another hashmap? Tried to put("os", "docs.openstack.Org/compute/api/v1.1"); too, without success – Yoann Couble Aug 5 at 14:07 sorry, the namespace should of course start with "http://".

(How can I get a http ref display without interference? ). The binding should go in the same hashmap.

– forty-two Aug 5 at 14:10 well, I think I have the same problem with "os". Tried to select the servers node like this : selectNodes("/os:servers", xmlDoc, namespaces) and it returned null.(Yes, I added "os" bind in the same hashmap) – Yoann Couble Aug 5 at 14:21.

For those who have or will have the same problem, I write here the solution I chose. As the problem comes from the Document builder, and that getXml function does not set the document aware of namespaces, you have to replace that function. Code from lighthouse : public Document getXml(HttpResponse response, String encoding) { try { InputSource source = new InputSource(response.getStream()); source.

SetEncoding(encoding); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory. SetNamespaceAware(true); DocumentBuilder builder = factory. NewDocumentBuilder(); builder.

SetEntityResolver(new NoOpEntityResolver()); return builder. Parse(source); } catch (Exception e) { throw new RuntimeException(e); } } And instead of retrieving your DOM Document like that : Document doc = WS. Url("http://www.yoursource.com").get().getXml(); You should use instead : getXml(WS.

Url("http://www.yoursource.com").get(),"UTF-8").

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions