将 php 脚本移植到 golang 时遇到问题。golang中有没有类似于php的方法:$processRefList = $faceContainer->getElementsByTagName('processRef');有一个 xml 文件,其中包含大量名为processRef.所以我需要在不处理嵌套结构树的情况下收集所有这些元素。这是xml的示例部分:<face><processes> <process group="1" type="regular"/> <process group="2" type="spotUV" state="off"/></processes><assets>...</assets><groups> <group id="1"> <assetRefs> <imageRef ref="1" x="0" y="0" id="8"> <processRefs> <!-- This applies spotUV to this asset and removes the regular process. --> <processRef ref="1" state="off"/> <processRef ref="2" state="on"/> </processRefs> </imageRef> <textRef ref="1" x="161" y="41" id="7"/> <textRef ref="2" x="160" y="55" id="6"> <processRefs> <!-- This applies spotUV to this asset and also leaves regular process applied. --> <processRef ref="2" state="on"/> </processRefs> </textRef> </assetRefs> </group> <group id="2">...</group></groups>
3 回答
梦里花落0921
TA贡献1772条经验 获得超6个赞
尝试这个
$extractvar = new DOMDocument();
$extractvar ->load("yourfile");
$itemextract= $extractvar ->getElementsByTagName("faceContainerRefs");
foreach( $itemextract as $value )
{
$var1= $value->getElementsByTagName("faceContainerRef ");
$var= $var1->item(0)->nodeValue;
}
- 3 回答
- 0 关注
- 165 浏览
添加回答
举报
0/150
提交
取消