[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Bugs?

Subject: Re: Bugs?
From: Keith Visco <kvisco@xxxxxxxxx>
Date: Mon, 19 Apr 1999 09:26:11 -0400
keith pazera
Edas,

#getNodeValue will not return you the contents of an element.

You will need to get the children of the element, and concatenate all
the Text and CDATASection nodes, so something like:

NodeList nl = node.getChildNodes();
// handle only the first child
StringBuffer value = new StringBuffer();
if (nl.getLength() > 0) {
   nl = nl.item(0).getChildNodes();
   for (int i = 0; i < nl.getLength(); i++) {
      Node temp = nl.item(i);
      if ((temp.getNodeType() == Node.TEXT) || 
         (temp.getNodeType() == Node.CDATA_SECTION_NODE)) {
         value.append( ((Text)temp).getData() );
      }
   }
}

--Keith

Edas Pazera wrote:
> 
> OK, someone tell me I am not crazy yet... :-)
> 
> I have tried all ways I could think of, but I still can't get a simple
> function return the value of a child node.
> 
> It is my assumption--confirmed by OpenXML API documentation--that the
> following line--
> 
> node.getChildNodes().item(0).getNodeValue()
> 
> would return "A" as defined in the XML code below--
> 
> <parent>
>         <child1>A</child1>
>             ...
>         <childN>Z</childN>
> </parent>
> 
> All I get is empty string!!!  I have no problem getting the name of the tag,
> but not the value?!  What am I missing here?
> 
> On the side note, I have to admit that while slowly and painfully weeding my
> way through servlets/xml/xsl, I am getting somewhere and am liking it a lot!
> Great effort from respective developers...
> 
> - Edas
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Bugs?
    • Edas Pazera - Mon, 19 Apr 1999 03:34:28 -0600
      • Keith Visco - Mon, 19 Apr 1999 09:26:11 -0400 <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.