OK I've tried what you suggested

I included a DTD and did
 parser.setIncludeIgnorableWhitespace(false);

but it still doesnt ignore all whitespaces (maybe I'm writing the DTD
incorrectly?)

here is the xml doc:
----
<?xml version="1.0"?> 
<!DOCTYPE address-book SYSTEM "address-book.dtd">

<address-book>
   <entry>
      <name>Jo Blo</name>
      <address>
         <street>3134 Broad Street</street>
         <city>Philadelphia</city>
         <state>Pennsylvania</state>
         <zip>19143</zip>
      </address>

      <tel>215-329-3134</tel>
      <fax>215-333-1234</fax>
      <email>[EMAIL PROTECTED]</email>
   </entry>
</address-book>

here is the DTD
-----
<!ELEMENT address-book (entry+)>

<!ELEMENT entry (name, address, tel*, fax*, email*)>

<!ELEMENT name (#PCDATA)>

<!ELEMENT address (street, city, state, zip)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city   (#PCDATA)>
<!ELEMENT state  (#PCDATA)>
<!ELEMENT zip    (#PCDATA)>

<!ELEMENT tel (#PCDATA)>

<!ELEMENT fax (#PCDATA)>

<!ELEMENT email (#PCDATA)>


        Node addressBook = root.getDocumentElement();
        Node entry = addressBook.getFirstChild();
        Node name = entry.getFirstChild();

name.getNodeValue() returns null
name.getFirstChild().getNodeValue() returns "Jo Blo"

if you want to reproduce my results, code, xml, and dtd are at 
http://gateway.homeip.net/~son/addressBook

thanks for any feedback,
son

On Fri, 26 Jan 2001, Son To wrote:
> ---------- Forwarded message ----------
> Date: 26 Jan 2001 15:08:38 -0800
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Re: Node.getFirstChild() wierdness
> 
> On Fri, 26 January 2001, Son To wrote:
> 
> nope - it's right - the text is the blank line between <address> and <street>
> 
> XML requires that the parser pass through all the text in the document 
> whether it's 'ignorable' or not. 
> 
> If you have a DTD then the DOM parser can tell what text is ignorable and you 
> can request that it not give it to you by setting 
> 
> parser.setIncludeIgnorableWhitespace(false)
> 
> if you don't have a DTD then it can't tell what's ignorable and hence it 
> can't leave it out. 
> 
> Roland
> > 
> > Hi,
> > I am using DOM. There seems to be an extra Node in the Document object
> > that is returned
> > 
> > for example, 
> > 
> > <address>
> >     <street>3134 Broad Street</street>
> >     <city>Philadelphia</city>
> >     <state>Pennsylvania</state>
> >     <zip>19143</zip>
> > </address>
> > 
> > document.getDocumentElement().getFirstChild().getNodeName() 
> > returns "#text" when I expected it to return "street"
> > 
> > root.getDocumentElement().getFirstChild().getNextSibling().getNodeName()
> > returns "street"
> > 
> > what is that "#text" being returned? Shouldn't the firstChild of address 
> > be street?
> > 
> > I tried various other xml documents, and "#text" is always the firstChild.
> > Am I misunderstanding the DOM tree? If so how is this address represented
> > in the DOM tree?
> > 
> > thanks,
> > son
> > 
> > 
> > ---------------------------------------------------------------------
> > 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]
> 


Reply via email to