Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用XML::Twig打印元素名称_Xml_Perl_Xml Twig - Fatal编程技术网

如何使用XML::Twig打印元素名称

如何使用XML::Twig打印元素名称,xml,perl,xml-twig,Xml,Perl,Xml Twig,感谢这个论坛,我成功地编写了一个perl脚本来编辑xml文件。但是我想在屏幕上打印一些东西。我想显示更改前后的xml内容。请帮帮我 输入XML <config> <match_name>Match_20111010</match_name> <teamA>Alpha_2353523</teamA> <teamB>Beta_23523523</teamB> <result>Win</result&

感谢这个论坛,我成功地编写了一个perl脚本来编辑xml文件。但是我想在屏幕上打印一些东西。我想显示更改前后的xml内容。请帮帮我

输入XML

<config>
<match_name>Match_20111010</match_name>
<teamA>Alpha_2353523</teamA>
<teamB>Beta_23523523</teamB>
<result>Win</result>
</config>
使用
print()
函数来
STDOUT

$twig->print(\*STDOUT);
或仅打印标记名:

print STDOUT $tag->name;

整个
xml
文件要打印哪些内容?我不明白您的预期输出是什么,以及您当前的代码以何种方式无法工作。我对代码没有任何问题,我只想在标准输出屏幕上打印xml标记名,其中包含更改前后的值。像这样的。不知道如何使用Twig模块只打印xml文件的标记名。我正在使用parse_inplace来写入对xml文件的更改。因此edittag子目录下的print语句也被写入xml文件。对不起,输出有点笨拙。在XML::Twig中是否有只提取元素名的选项。这里我想要的是
print“XML标记名:旧元素值”print“XML标记名:新元素值”
@chidori:print STDOUT$TAG->name如何?谢谢,这很有效。你能解释一下STDOUT代表什么以及它与STDOUT有什么不同吗@chidori:据我所知,typeglob是将文件句柄传递给函数的方式,
STDOUT
是在
perl
中默认打开的文件句柄,所以我直接将其用于标准的
print
函数。
print STDOUT $tag->name;