gpt4 book ai didi

xml - 在 perl 中使用 libXML 将字符串转换为哈希

转载 作者:行者123 更新时间:2023-12-04 18:13:20 24 4
gpt4 key购买 nike

我有一个 xml 格式的字符串,我希望使用 LIBXML 将其转换为哈希。
我怎么能在 perl 中这样做?

最佳答案

Searching XML::LibXML 发行版,似乎对此类功能的支持仅限于属性,仅通过 XML::LibXML::AttributeHash .

报价 XML::LibXML::DOM :

One also has to remember, that XML::LibXML is an interface to libxml2 nodes which actually reside on the C-Level of XML::LibXML. This means each node is a reference to a structure different than a perl hash or array. The only way to access these structure's values is through the DOM interface provided by XML::LibXML. This also means, that one can't simply inherit an XML::LibXML node and add new member variables as they were hash keys.



然而,有大量 other modules可以散列 XML 字符串:
  • XML::Hash
  • XML::Twig
  • XML::Fast
  • XML::Simple
  • XML::Smart
  • 关于xml - 在 perl 中使用 libXML 将字符串转换为哈希,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12182129/

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