简体   繁体   English

如何使用Nokogiri更改xml中的节点名称

[英]How to change node name in xml with Nokogiri

I need to change 我需要改变

  <Bureau xmlns="http://www.bbc.com/namespace" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    </Bureau>

to

 <Bureau>
   </Bureau>

For this I use nokogiri gem. 为此,我使用了nokogiri宝石。 Also, I get this xml from request. 另外,我从请求中获取此xml。

I tried to make it with different methods:xpath,at_xpath.But can't replace it to node name which I need. 我试图用不同的方法来制作它:xpath,at_xpath。但是不能将其替换为我需要的节点名称。

doc = Nokogiri::XML(response)

Adding doc.remove_namespaces! 添加doc.remove_namespaces! work for me 为我工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM