ANT : XmlParse

XmlParse
Implement XML format file analysis
Parameters
Attribute Description Required
file XML file path One of the two must be set
xml XML content to parse
prefix Valid xpath prefixes when parsing XML tags YES
params A list of valid variable parameters with valid xpath prefixes; if this parameter is not set, all analysis results are set as user properties, and when this parameter is set, it is set as a dynamic variable (recommended). No, default false
keepgoing Whether to continue execution when a sequential error occurs No, default false

Example:
XML文件内容:<?xml version="1.0" encoding="UTF-8"?><cfx> <EmpInfo> <psnid>0016</psnid> <psncode>0016</psncode> <psnname>0016</psnname> <idno>0016</idno> <psnclcode>1</psnclcode> <email>[email protected]</email> <phone>0016</phone> <tel/> <psnclname>在职人员</psnclname> <deptcode>10000</deptcode> <indutydate>2002-03-11T00:00:00</indutydate> <deleted>0</deleted> </EmpInfo><EmpInfo> <psnid>0017</psnid> <psncode>0017</psncode> <psnname>0017</psnname> <idno>0017</idno> <psnclcode>1</psnclcode> <email>[email protected]</email> <phone>0017</phone> <tel/> <psnclname>在职人员</psnclname> <deptcode>10000</deptcode> <indutydate>2002-03-11T00:00:00</indutydate> <deleted>0</deleted> </EmpInfo></cfx>

<taskdef name="xmlparse" classname="com.nantian.job.task.XmlParseTask"/><!-- 使用用户属性 --><xmlparse file="d:/EmpInfo_HR2PT.xml" prefix="cfx.EmpInfo"><sequential><echo>${psnid}|${psncode}|${psnname}</echo></sequential></xmlParse><!-- 使用动态属性 --><xmlParse file="d:/EmpInfo_HR2PT.xml" prefix="cfx.EmpInfo" params="psnid,psncode,psnname"><sequential><echo>@{psnid}|@{psncode}|@{psnname}</echo></sequential></xmlparse>
1.先创建一个xml文件,(test.xml)
注意的是:文件的编码要是utf-8,不然解析不了。
bug:出现编码错误

效果就是:把xml文件里面定义的节点数据进行解析输出。


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324534422&siteId=291194637
ANT
ANT