如何从XML文档JAVA中的多个xpath实例中获取文本

时间:2015-10-16 23:19:28

标签: java xml dom xpath

我想从同一XPATH的多个实例中获取文本值,这些实例出现在XML文档的不同部分中。例如:

<explanation>
<NodeExplanations>
    <IDAfterSkipProcessing>/Temporary/EIC/EarnedIncomeWorksheetPP/SpouseLongSESelfEmploymentTaxAmtNotBlank</IDAfterSkipProcessing>
    <NodeExplanation>
        <Title>Spouse's self-employment tax</Title>
        <Phrase>
            <Text>your spouse does not have self-employment tax</Text>
        </Phrase>
        <Question>
            <Text>Why doesn't my spouse have self-employment tax?</Text>
        </Question>
        <ExplanationText>
            <Text>We can't get any more details on </Text>
            <NodeName>
                <Text>your spouse does not have self-employment tax</Text>
            </NodeName>
            <Text> right now.</Text>
        </ExplanationText>
    </NodeExplanation>
<NodeExplanations>  
</explanation>

我想解析出来:

1. "We can't get any more details on "
2. "your spouse does not have self-employment tax"
3. " right now."

如何从提到的XPATH中获取文本值?我想避免使用DOM

0 个答案:

没有答案