Org.w3c.dom.Node with Android version less than 2.2

getTextContent () is not a recognized function. getNodeValue () works fine for strings, but anytime when I try to parse a number using getNodeValue (), it returns null!

How can I parse Long from XML using this class?

+3
source share
3 answers

The main reason for this is that the method getTextContent()is a W3C DOM Level 3 method; see the changes section of the core DOM level 3 specification.

The Node interface has two new attributes: Node.baseURI and Node.textContent ....

and getTextContent()is the getter for the new attribute.

(Presumably, older versions of Android do not implement a level 3 API.)

getTextContent() ; . textContext. , Node () , node.getTextContext() node.getFirstChild().getNodeValue().

+6

node. , - :

<val>10000</val>

XML node , , , node "10000".

valNode.getFirstChild().getNodeValue()
+3

: "getNodeValue() ", :

Long l = Long.getLong(node.getNodeValue());

. getNodeValue() String, .

, , node (, )?

0
source

Source: https://habr.com/ru/post/1787216/


All Articles