Need to make a correction in my previous mail.
I got " org.apache.xerces.dom.ElementNSImpl" when I execute
"doc.getElementsByTagName("P")" and then "getClass().getName()". I expect I
get "org.apache.html.dom.HTMLParagraphElementImpl"
The body element is "org.apache.html.dom.HTMLBodyElementImpl" which is what
I expect, but the Paragraph element is different.
Could some one please explain to me why?
Thanks.
Output I got is :
document-class-name: org.apache.html.dom.HTMLDocumentImpl
paragraphs: 2
elm: org.apache.html.dom.HTMLBodyElementImpl
class name org.apache.xerces.dom.ElementNSImpl
class name org.apache.xerces.dom.ElementNSImpl
Test program:
DOMParser parser = new DOMParser();
parser.parse(new InputSource(new FileInputStream("Yahoo!.htm")));
HTMLDocument doc = (HTMLDocument) parser.getDocument();
System.out.println("document-class-name: " + doc.getClass().getName());
System.out.println("paragraphs: " +
doc.getElementsByTagName("P").getLength());
HTMLElement elm = doc.getBody();
System.out.println("elm: " + elm.getClass().getName());
NodeList n = doc.getElementsByTagName("P");
for (int i = 0; i < n.getLength(); i++) {
System.out.println("class name " + n.item(i).getClass().getName());
}
-----Original Message-----
From: Samuel Cheung [mailto:[EMAIL PROTECTED]
Sent: Monday, May 06, 2002 11:08 PM
To: '[EMAIL PROTECTED]'
Subject: DOM create by Neko HTML Parser
Hi,
I think Neko HTML Parser creates a W3C HTML DOM (in org.apache.html.dom) for
the html document. But when I print the class name of the "P" element of a
document I parse, I got the class name "
org.apache.xerces.dom.DeepNodeListImpl" instead of "
org.apache.html.dom.HTMLParagraphElementImpl" that I expected.
Could someone please tell me if I am missing anything or my assumption is
incorrect?
Thanks.
----------------------------------------------------------------------------
---
// Output of Test code
document-class-name: org.apache.html.dom.HTMLDocumentImpl
paragraphs: 2
class name org.apache.xerces.dom.DeepNodeListImpl <--- *****
class name org.apache.xerces.dom.DeepNodeListImpl
// Test code
DOMParser parser = new DOMParser();
parser.parse(new InputSource(new DebugInputStream(new
FileInputStream("Yahoo!.htm"))));
HTMLDocument doc = (HTMLDocument) parser.getDocument();
System.out.println("document-class-name: " + doc.getClass().getName());
System.out.println("paragraphs: " +
doc.getElementsByTagName("P").getLength());
NodeList n = doc.getElementsByTagName("P");
for (int i = 0; i < n.getLength(); i++) {
System.out.println("class name " + n.getClass().getName());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]