gpt4 book ai didi

ruby - Xpath 在 Nokogiri 中不返回任何内容

转载 作者:数据小太阳 更新时间:2023-10-29 01:53:10 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Nokogiri/Xpath namespace query

假设有XML

<?xml version="1.0" encoding="utf-8"?> 
<SomeResponse xmlns="some_namespace">
<Timestamp>......</Timestamp>
<Ack>Failure</Ack>
<Errors>
<ShortMessage>ShortMessage111.</ShortMessage>
<LongMessage>LongMessage111.</LongMessage>
<ErrorCode>1</ErrorCode>
<SeverityCode>Warning</SeverityCode>
</Errors>
<Errors>
<ShortMessage>ShortMessage222.</ShortMessage>
<LongMessage>LongMessage222.</LongMessage>
<ErrorCode>2</ErrorCode>
<SeverityCode>Warning2</SeverityCode>
</Errors>
<!-- there might be many Errors nodes -->
<Version>123</Version>
<Build>122345abt_3423423</Build>
</SomeResponse>

我尝试使用 Nokogiri 查找所有错误及其长消息和短消息。

我在做:

doc = Nokogiri.XML(xml)
errors = doc.xpath("//Errors")
puts errors

errors2 = doc.xpath("//Errors//ShortMessage")
puts errors

它什么也没显示。

我做错了什么?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com