attribute.cc
来自「c语言编写的xml解析器可以方便的遍历插入删除节点等操作的」· CC 代码 · 共 62 行
CC
62 行
/* xml++.cc * libxml++ and this file are copyright (C) 2000 by Ari Johnson, and * are covered by the GNU Lesser General Public License, which should be * included with libxml++ as the file COPYING. */#include "libxml++/attribute.h"#include <libxml/tree.h>namespace xmlpp{Attribute::Attribute(xmlNode* node) : Node(node){}Attribute::~Attribute(){}std::string Attribute::get_name() const{ return cobj()->name ? (char*)cobj()->name : "";}std::string Attribute::get_value() const{ xmlChar *value = xmlGetProp(cobj()->parent, cobj()->name); std::string retn = value ? (char *)value : ""; xmlFree(value); return retn;}void Attribute::set_value(const std::string& value){ xmlSetProp(cobj()->parent, cobj()->name, (xmlChar*)value.c_str());}xmlAttr* Attribute::cobj(){ // yes, this does what it looks like: it takes an xmlNode pointer // and *reinterprets* it as an xmlAttr pointer // -stefan return reinterpret_cast<xmlAttr*>(Node::cobj());}const xmlAttr* Attribute::cobj() const{ // yes, this does what it looks like: it takes an xmlNode pointer // and *reinterprets* it as an xmlAttr pointer // -stefan return reinterpret_cast<const xmlAttr*>(Node::cobj());}} //namespace xmlpp
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?