ohxsy 发表于 30-1-2015 16:27:18

有IT大神帮忙下吗, 有偿的

本帖最后由 ohxsy 于 30-1-2015 16:41 编辑

用JAVA语言 用一定的方法解析多个xml文件(他们的格式是一样的),抽取出一些指定标签里的内容,并对不同的内容按三种格式中的一种进行显色输出,同时把一些属性抽取出来放在各自的list里,以下是xml文件里的一部分

<?xml version="1.0"?>
<!DOCTYPE source_file SYSTEM "apf.v5.1.1.dtd">
<source_file URI="CNR20001109.1700.1220.sgm" SOURCE="broadcast news" TYPE="text" AUTHOR="LDC" ENCODING="UTF-8">
<document DOCID="CNR20001109.1700.1220">
<entity ID="CNR20001109.1700.1220-E1" TYPE="VEH" SUBTYPE="Land" CLASS="SPC">
<entity_mention ID="CNR20001109.1700.1220-E1-1" TYPE="NOM" LDCTYPE="NOM">
    <extent>
      <charseq START="64" END="69">中国福建汽车</charseq>
    </extent>
    <head>
      <charseq START="68" END="69">汽车</charseq>
    </head>
</entity_mention>
</entity>
In this exampleit need extaract out 汽车 to out put in color.

艾瑞克 发表于 30-1-2015 16:44:47

去 www.freelancer.com.au

superopengl 发表于 30-1-2015 17:34:16

I think it's simple if by Xpath.

Mr.Q 发表于 30-1-2015 18:02:07

用正则两行代码搞定。。

zymzxq 发表于 30-1-2015 18:13:05

我的第一反应是遍历dom,:D

superopengl 发表于 30-1-2015 18:17:08

Mr.Q 发表于 30-1-2015 16:02
用正则两行代码搞定。。

Yes, butsince it's XML, using XML way should be more readable.

nkcoder 发表于 6-2-2016 00:04:57

用XPath或beautifulsoup应该不难搞定
页: [1]
查看完整版本: 有IT大神帮忙下吗, 有偿的