使用DOM Parser解析XML

时间:2015-09-03 16:24:36

标签: java dom

我正在使用DOM解析器来解析XML。 xml格式为:

<PriceList>
        <PriceTag>
            <Pricing priceCode = "EATIN">
                <Price></Price>
                <Tax
                    taxCode = "ALWAYS"
                    rule = "TAX_CHAIN"
                    entry = "4"/>
            </Pricing>
            <Pricing priceCode = "TAKEOUT">
                <Price></Price>
                <Tax
                    taxCode = "ALWAYS"
                    rule = "TAX_CHAIN"
                    entry = "4"/>
            </Pricing>
            <Pricing priceCode = "OTHER">
                <Price></Price>
                <Tax
                    taxCode = "ALWAYS"
                    rule = "TAX_CHAIN"
                    entry = "4"/>
            </Pricing>
        </PriceTag>
    </PriceList>

如果priceCode =“EATIN”,我想看看价格。

任何人都可以帮我实现这个目标。

1 个答案:

答案 0 :(得分:0)

尝试替换此行 fileName = ((FileSplit)context.getInputSplit()).getPath().toString();fileName = context.getConfiguration().get("mapreduce.input.fileinputformat.inpu‌​tdir", null);

。{