How to get attributes from a node in libxml2

前端 未结 6 2030
孤街浪徒
孤街浪徒 2020-12-20 18:32

I am working on a parser to get data from an XML file. I am using libxml2 to extract data. I am a not able to get the attributes from nodes. I only found nb_attributes

6条回答
  •  有刺的猬
    2020-12-20 19:25

    The easiest way I found using libxml2 (through libxml++ in C++) was to use the eval_to_XXX methods. They evaluate an XPath expression, so you need to use the @property syntax.

    For example:

    std::string get_property(xmlpp::Node *const &node) {
        return node->eval_to_string("@property")
    }
    

提交回复
热议问题