【发布时间】:2014-01-23 02:34:45
【问题描述】:
这是我的问题:我需要使用 SAX Parser 提取标签“p”之间的文本,而不使用 XML 表示法
<title>1. Introduction</title>
<p>The Lorem ipsum
<xref ref-type="bibr" rid="B1">
1
</xref>.
Lorem ipsum 23.
</p>
<p>The L domain recruits an ATP-requiring cellular factor for this
scission event, the only known energy-dependent step in assembly
<xref ref-type="bibr" rid="B2">
2
</xref>.
Domain is used here to denote the amino
acid sequence that constitutes the biological function.
</p>
是否可以使用 endElement() ?因为当我使用它时,我只获得“/xref”标签之后的部分
这里是代码
public void endElement(String s, String s1, String element) throws SAXException {
if(element.equals(Finals.PARAGRAPH)){
Paragraph paragraph = new Paragraph();
paragraph.setContext(tmpValue);
System.out.println("Contesto: " + tmpValue);
listP.add(paragraph);
}
}
@Override
public void characters(char[] ac, int i, int j) throws SAXException {
tmpValue = new String(ac, i, j);
}
这是我期望做的:包含两个段落的列表listP:
1) Lorem ipsum 1 Lorem ipsum 23.
2) The L domain recruits an ATP-requiring cellular factor for this
scission event, the only known energy-dependent step in assembly 2
Domain is used here to denote the amino
acid sequence that constitutes the biological function.
【问题讨论】:
-
因为显然
endElement是在...结束元素上调用的。您对名为 CDATA 的部分感兴趣。您应该为此找到合适的处理程序。你应该使用你的实际代码来展示你当前的尝试。 -
看来你做得很好。问题出在哪里?
-
我需要这个结果
The L domain recruits an ATP-requiring cellular factor for this scission event, the only known energy-dependent step in assembly 2. Domain is used here to denote the amino acid sequence that constitutes the biological function.,但我只得到Domain is used here to denote the amino acid sequence that constitutes the biological function.
标签: java xml parsing saxparser