I am trying to build a function which traverse a Dom tree if and only if the node name is not equal to script
and style
. here is the function:
public static void PostOrderTR(Node node) throws XPathExpressionException, MalformedURLException, SAXNotRecognizedException, SAXNotSupportedException, ParserConfigurationException, IOException, SAXException
{
if (node == null || node.getNodeName() == null)
{
return;
}
if(!"script".equals(node.getNodeName())||!"style".equals(node.getLocalName())|| !"style".equals(node.getNodeName()))
{
//do something
PostOrderTR(node.getFirstChild());
}
if(!"script".equals(node.getNodeName())||!"style".equals(node.getLocalName())|| !"style".equals(node.getNodeName()))
PostOrderTR(node.getNextSibling());
}
but in practice, it results exactly opposite. it goes through all nodes including the script
and style
. I already tried to replace&&
with ||
and nothing changed much.
Aucun commentaire:
Enregistrer un commentaire