Hi all,
I am trying to detetct/work around this bug in RSS elements. That means I have to find a wrong namespace-declaration and change its value to the correct namespace. E.g:
xmlns:media="http://search.yahoo.com/mrss"
must be:
xmlns:media="http://search.yahoo.com/mrss/"
How can I achive that given a org.w3c.Document?
I meanwile found out how to get all elements of a certain namespace:
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
XPathExpression expr = xpath.compile("//*[namespace-uri()='http://search.yahoo.com/mrss']");
Object result = expr.evaluate(d, XPathConstants.NODESET);
if (result != null) {
NodeList nodes = (NodeList) result;
for(int node=0;node<nodes.getLength();node++)
{
Node n = nodes.item(node);
this.log.warn("Found old mediaRSS namespace declaration: "+n.getTextContent());
}
}
So now I have to figure out how to change the namespace of a Node via JAXP.