简体   繁体   English

在生物学中将Java用于XML数据集

[英]using java for XML data set in biology

I wrote a code in java for parsing an xml file that meant to be used. 我用Java编写了一个代码,用于解析要使用的xml文件。 and now i have problem. 现在我有问题。 my data set is AIMed and is something like this: 我的数据集是AIMed,是这样的:

<passage>
    <text>
        Isolation of human delta-catenin and its binding specificity with presenilin 1.
        We screened proteins for interaction with presenilin (PS) 1, and cloned the full-length cDNA of human delta-catenin, which encoded 1225 amino acids.
        Yeast two-hybrid assay, GST binding assay and immunoprecipitation demonstrated that delta-catenin interacted with a hydrophilic loop region in the endoproteolytic C-terminal fragment of PS1, but not with that of PS-2.
        These results suggest that PS1 and PS2 partly differ in function.
        PS1 loop fragment containing the pathogenic mutation retained the binding ability.
        We also found another armadillo-protein, p0071, interacted with PS1.
    </text>
    <annotation id="T1">
        <infon key="file">ann</infon>
        <infon key="type">protein</infon>
        <location offset="19" length="13"></location>
        <text>delta-catenin</text>
    </annotation>
    <relation id="R3">
        <infon key="relation type">Interaction</infon>
        <infon key="file">ann</infon>
        <infon key="type">Relation</infon>
        <node refid="T5" role="Arg1"></node>
        <node refid="T6" role="Arg2"></node>
    </relation>
</passage>

and i'm using SAXParser and my code is like this(for text tag): 我正在使用SAXParser ,我的代码是这样的(用于文本标签):

else if (bText) 
{
     System.out.println("Text: " 
     + new String(ch, start, length));
     bText = false;
}

but it shows only two senteces. 但它仅显示两个句子。 my question is how to fix it? 我的问题是如何解决?

Walk through the nodes in your NodeList until you find the corresponding node, cast it to an element (in your case text), then use element.getTextContent(). 遍历NodeList中的节点,直到找到相应的节点,将其转换为元素(在您的情况下为文本),然后使用element.getTextContent()。 See for it Interface Node , and think that it will also return the text of the node descendants (if they exist). 为其查看Interface Node ,并认为它还将返回节点后代的文本(如果存在)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM