简体   繁体   English

遍历XML中的节点

[英]Traverse nodes in XML

I need to traverse the nodes of an xml file in another xml file. 我需要遍历另一个xml文件中的xml文件的节点。 So i have just loaded the second file into my current XML file and i need to run a loop around this file to find nodes with a certain tag. 因此,我刚刚将第二个文件加载到当前XML文件中,并且需要围绕该文件运行循环以查找具有特定标签的节点。 How do i do this in XML? 如何在XML中做到这一点?

<loadfile
      property="changed.files"
      srcFile="log.xml">
</loadfile>

Loaded my file this way now i tried to use ant-contrib task which has a for loop but i need to run it on diff machines and ant-contrib is not a task that comes by default with ant so i need to add that into the ant configuration as well so this is not ideal. 现在我以这种方式加载了文件,我尝试使用具有for循环的ant-contrib任务,但是我需要在diff机器上运行它,而ant-contrib并不是ant默认附带的任务,因此我需要将其添加到蚂蚁配置,所以这不是理想的。 Any suggestions how i traverse nodes in XML? 任何建议如何遍历XML中的节点?

Ant doesn't have great facilities built-in for traversing XML. Ant没有内置的用于遍历XML的强大功能。 You'd probably do well to grab the excellent XMLTASK Library and include the jar for it in something like a /tools directory in your project. 您可能会很好地获取出色的XMLTASK库,并将其jar包含在项目中的/ tools目录中。

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

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