xmllint – Help formulating a query. ( XPath set is empty ) error

huangapple go评论55阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月15日 03:24:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76476936.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定