我解析它代表的研究論文/ artciles的XML文件,並有XML架構之下在MySQL數據庫中存儲在Java中解析XML文件,以獲得特定的文本內容
<article>
<article-meta></article-meta>
<body>
<p>
Extensible Markup Language (XML) is a markup language that defines a set of
rules for encoding documents in a format that is both human-readable and machine-
readable <ref id = 1>. It is defined in the XML 1.0 Specification produced by the
W3C, and several other related specifications
</p>
<p>
Many application programming interfaces (APIs) have been developed to aid
software developers with processing XML <ref id = 2>. data, and several schema
systems exist to aid in the definition of XML-based languages.
</p>
</body>
<back>
<ref-list>
<ref id = 1>Details about this reference </ref>
<ref id = 2>Details about this reference </ref>
</ref-list>
</back>
</article>
我解析使用DOM文件解析器。其中一個要求是每個ref ID,我必須從身體標籤中引用的位置提取150個左右的字符。我怎樣才能做到這一點 ??
refId leftText rightText
1 left 150 150 chars on right side
做XPATH – MadProgrammer