抱歉刚才记错了 应该在这 org.w3c.dom Interface Node 方法名称为:getNodeValue 帮助信息为: public String getNodeValue() throws DOMExceptionThe value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect. Throws: DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation
使用JDOM. Document doc = new Document( new Element("a") ); String strValue = doc.getRootElement().getText();
123回被当做一个文本节点,是<a>的第一个子节点 Text value = node.getFirstNode(); // 拿到 String strValue = value.getData(); // 转换 然后随便你怎麽样
应该在这
org.w3c.dom
Interface Node
方法名称为:getNodeValue
帮助信息为:
public String getNodeValue()
throws DOMExceptionThe value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect. Throws:
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation
Document doc = new Document( new Element("a") );
String strValue = doc.getRootElement().getText();
Text value = node.getFirstNode(); // 拿到
String strValue = value.getData(); // 转换
然后随便你怎麽样
node 为包含该值的节点。
String value=node.getFirstChild().getNodeValue())