所以我目前正在使用SAX尝试从我正在使用的许多xml文档中提取一些信息.到目前为止,提取属性值非常容易.但是,我不知道如何从文本节点中提取实际值.
例如,在给定的XML文档中:
<w:rStyle w:val="Highlight" />
</w:rPr>
</w:pPr>
- <w:r>
<w:t>Text to Extract</w:t>
</w:r>
</w:p>
- <w:p w:rsidR="00B41602" w:rsidRDefault="00B41602" w:rsidP="007C3A42">
- <w:pPr>
<w:pStyle w:val="Copy" />
Run Code Online (Sandbox Code Playgroud)
我可以通过从val获取值来提取"突出显示"没问题.但是我不知道如何进入该文本节点并获取"Text to Extract".
到目前为止,这是我的Java代码,用于提取属性值...
private static final class SaxHandler extends DefaultHandler
{
// invoked when document-parsing is started:
public void startDocument() throws SAXException
{
System.out.println("Document processing starting:");
}
// notifies about finish of parsing:
public void endDocument() throws SAXException
{
System.out.println("Document processing finished. \n");
}
// we enter to element 'qName':
public void startElement(String uri, String …Run Code Online (Sandbox Code Playgroud)