W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2000

text nodes and element nodes

From: andrew atkinson <andrew@wellengaged.com>
Date: Mon, 10 Apr 2000 18:25:24 -0400 (EDT)
Message-ID: <38F25518.AC73483F@wellengaged.com>
To: www-dom@w3.org
Hi

I'm not sure what is going on here. We have the following code segment

String xmlSid = SessionManager.createNewSession("edmunds", "0");
    StringBufferInputStream sbisd = new StringBufferInputStream(xmlSid);

    InputSource isid = new InputSource(sbisd);
    Element sessionInfo =
this.xspParser.parse(isid).getDocumentElement();

This returns us the correct Element, however when we work through the
Element to get the required node, it has ELEMENT_NODE type, this means
we can't retrive the value

the Element looks like

<SESSION>
  <SESSIONID>1234567865645</SESSIONID>
  <COMMUNITYID>12837743837379182</COMMUNITYID>
</SESSION>

the code we use to try and get the value is

NodeList sessionTag = sessionInfo.getElementsByTagName("*");
Node st = sessionTag.item(0);
String sid = st.getNodeValue();

However as I said the Node st is of type ELEMENT_NODE, I seem to have no
control over this, what can I do to ensure its a text node, which it
looks like to me?

Cheers
Andrew
Received on Monday, 10 April 2000 18:33:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:47 GMT