使用 LibXML-Ruby 清除不需要的命名空间
我想解析 Atom Feed 并为每个条目创建一个符合 Atom 的缓存。
问题在于某些 Feed(例如此< /a>) 除了 Atom 之外还有许多命名空间。
是否可以完整保留所有 Atom 节点并删除属于另一个名称空间的每个节点?
像这样的事情:
valid_nodes = entry.find('atom:*', '/atom:feed/atom:entry')
# now I need to create an xml string with valid_nodes, but how I do that?
I would like to parse an Atom Feed and create an Atom-compliant cache of each Entry.
The problem is that some feeds (this one for example) have many namespaces other than the Atom one.
Is it possible to keep intact all Atom nodes and remove each node that belongs to another namespace?
Something like this:
valid_nodes = entry.find('atom:*', '/atom:feed/atom:entry')
# now I need to create an xml string with valid_nodes, but how I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 XSLT 中,您可以使用此转换:
这会逐字复制所有节点,如果它们
,也许您可以使用它。
In XSLT you could use this transformation:
This copies all nodes verbatim, if they are
Maybe you can use that.