Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 16584 invoked from network); 17 Aug 2007 10:58:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Aug 2007 10:58:55 -0000 Received: (qmail 80937 invoked by uid 500); 17 Aug 2007 10:58:51 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 80858 invoked by uid 500); 17 Aug 2007 10:58:51 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 80849 invoked by uid 99); 17 Aug 2007 10:58:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2007 03:58:51 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2007 10:59:14 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7878B71420A for ; Fri, 17 Aug 2007 03:58:30 -0700 (PDT) Message-ID: <3010888.1187348310482.JavaMail.jira@brutus> Date: Fri, 17 Aug 2007 03:58:30 -0700 (PDT) From: "Vladimir (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (JXPATH-99) JXPath works incorrectly with CyberNeko HtmlParser In-Reply-To: <9131283.1187300970523.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/JXPATH-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12520517 ] Vladimir commented on JXPATH-99: -------------------------------- I've added a method, that searches nodes with specified attribute values through the document tree, and it returnes desired node. //------------- // call for the above example: findByAttr(doc, "name", "q"); // similar to //*[@name='q'] //------------ private static Node findByAttr(Node node,String name, String s) { if (node instanceof Element) { Element el = (Element) node; if (el.getAttribute(name).equals(s)) { return el; } } for (int i=0; i JXPath works incorrectly with CyberNeko HtmlParser > -------------------------------------------------- > > Key: JXPATH-99 > URL: https://issues.apache.org/jira/browse/JXPATH-99 > Project: Commons JXPath > Issue Type: Bug > Affects Versions: 1.2 Final > Reporter: Vladimir > > I don't know exactly where is the bug. I have an idea, that CyberNeko html parser creates some wired w3c DOM representation of html file, and that is the cause. Here is a code sample: > // --------------------------- > // create CyberNeko html parser > DOMParser parser = new DOMParser(); > // this page does have //input[@name='q'] field > parser.parse("http://google.com"); > Document doc = parser.getDocument(); > // JXPATH TEST > JXPathContext context = JXPathContext.newContext(doc); > List nodes1 = context.selectNodes("//input[@name='q']"); // ERROR IS HERE: call returns nothing, must return 1 node > List nodes2 = context.selectNodes("//*"); // returnes 78 nodes > System.out.println(nodes1.toString()); > System.out.println(nodes2.toString()); > // XPathFactory TEST ( for comparison ) > // error, returns nothing > Object list1 = XPathFactory.newInstance().newXPath().compile("//input[@name='q']").evaluate(doc, XPathConstants.NODESET); > // returns 79 nodes > Object list2 = XPathFactory.newInstance().newXPath().compile("//*").evaluate(doc, XPathConstants.NODESET); > System.out.println(list1); > System.out.println(list2); > // ----------------------------------- > Is it possible to fix this problem inside JXPath? Or is it only html parser problem? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.