I tried iterating the whole dom tree. It gave me three
nodes. But the second nodes I got use nodelist.item(1)
is null. I tried several pasers, the result is the
same. Is it related to my environment? I am using VA
java. And I also imported the Xerces 2 into the
workspace.

thanks/lance
--- Hasan Sheboul <[EMAIL PROTECTED]> wrote:
> Are you expecting to get the text in the element
> <b>?
> 
> This code is not accurate, since if you supply the
> same XML document without
> the corresponding DTD
> e.g. <!ELEMENT a (b)>
>  then the first child, that you expect to be <b>
> element, will  be a
> whitespace, which in turn is a #PCDATA, and not an
> element.
> 
> Try to iterate over the whole DOM tree, also have a
> look at the sample code
> examples that come with the xercesJ-2.
> 
> Lance Zhang wrote:
> 
> > OK,
> >
> > The code is like
> >
> > DocumentBuilderFactory
> > factory=DocumentBuilderFactory.newInstance();
> > DocumentBuilder
> builder=factory.newDocumentBuilder();
> > Document doc=builder.parse(new File("c:/a.xml");
> > String
> >
>
value=doc.getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
> > //value come back something like ||
> >
> > a.xml
> > <?xml version="1.0" ?>
> > <a>
> >     <b>This is a test</b>
> > </a>
> >
> > thanks/lance
> >
> > --- Xuemin Guan <[EMAIL PROTECTED]> wrote:
> > > When posting such a question, it will be very
> > > helpful if the code snippet
> > > and xml sample
> > > file can be included.
> > >
> > > ----- Original Message -----
> > > �??信�??: "Lance Zhang" <[EMAIL PROTECTED]>
> > > �?�?^ : <[EMAIL PROTECTED]>
> > > �??信�-��?, : 2002�?�??8�-?18:09
> > > 件�?? : Problem in Dom parser
> > >
> > >
> > > > Hi,
> > > >
> > > > I got a problem when using DOM parser in
> > > > javax.xml.parsers package.
> > > >
> > > > I can not use getNodeValue() to get a text
> node
> > > value.
> > > > It return me some strange characters in doing
> that
> > > > although it is a very simple xml file.
> > > >
> > > > Also, the node.getElementsByTagName always
> return
> > > me
> > > > an empty nodelist although it was obvious not
> > > null.
> > > >
> > > > Does anyone have same kind of experience? does
> > > this
> > > > related to the encoding?
> > > >
> > > > thanks/Lance
> > > >
> > > >
> __________________________________________________
> > > > Do You Yahoo!?
> > > > Yahoo! Movies - coverage of the 74th Academy
> > > Awards®
> > > > http://movies.yahoo.com/
> > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > 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]
> > >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Movies - coverage of the 74th Academy
> Awards�
> > http://movies.yahoo.com/
> >
> >
>
---------------------------------------------------------------------
> > 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]
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards�
http://movies.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to