英文:
xmllint - Help formulating a query. ( XPath set is empty ) error
问题
I was expecting the command to return (10.236.227.110)。
我原本期望这个命令返回 (10.236.227.110)。
英文:
I have the output from an ( INFOBLOX ) IP lookup and want to manipulate the output. I can't seem to formulate the correct syntax to pull the IP address out of the ( .xml ) output.
I am trying to pull out the <ipv4addr>
tag but everything I have tried so far returns XPath set is empty
.
# cat test.xml | xmllint --xpath "//ipv4addr/value/text()" -
XPath set is empty
[ test.xml ]
<?xml version="1.0"?>
<list>
<value type="object">
<name>idrac-layton-jasmine.ecs.fln.lab.emc.com</name>
<ipv4addrs>
<list>
<value type="object">
<configure_for_dhcp type="boolean">true</configure_for_dhcp>
<_ref>record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQuX2RlZmF1bHQuY29tLmVtYy5sYWIuZmxuLmVjcy5pZHJhYy1sYXl0b24tamFzbWluZS4xMC4yMzYuMjI3LjExMC4:10.236.227.110/idrac-layton-jasmine.ecs.fln.lab.emc.com/default</_ref>
<mac>2c:ea:7f:5c:9c:67</mac>
<ipv4addr>10.236.227.110</ipv4addr>
<host>idrac-layton-jasmine.ecs.fln.lab.emc.com</host>
</value>
</list>
</ipv4addrs>
<_ref>record:host/ZG5zLmhvc3QkLl9kZWZhdWx0LmNvbS5lbWMubGFiLmZsbi5lY3MuaWRyYWMtbGF5dG9uLWphc21pbmU:idrac-layton-jasmine.ecs.fln.lab.emc.com/default</_ref>
<view>default</view>
</value>
</list>
I was expecting the command to return ( 10.236.227.110 )
答案1
得分: 0
尝试将您的xpath表达式更改为
"//ipv4addr/text()"
看看是否有效。
英文:
Try changing your xpath expression to
"//ipv4addr/text()"
and see if it works.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论