00001
00002
00003
00004
00005
00006 #ifndef _XML_HELPER_H_
00007 #define _XML_HELPER_H_
00008
00009 #include <libxml/parser.h>
00010
00011 namespace Limiro
00012 {
00013
00014 namespace xml
00015 {
00016
00017 xmlNodePtr nextSiblingByName(xmlNodePtr elem, const xmlChar *name);
00018 inline xmlNodePtr nextSiblingByName(xmlNodePtr elem, const char *name)
00019 {
00020 return nextSiblingByName(elem, (const xmlChar *)name);
00021 }
00022
00023 xmlNodePtr firstChildByName(xmlNodePtr elem, const xmlChar *name);
00024 inline xmlNodePtr firstChildByName(xmlNodePtr elem, const char *name)
00025 {
00026 return firstChildByName(elem, (const xmlChar *)name);
00027 }
00028
00029 const xmlChar *getAttributeContent(xmlNodePtr elem, const xmlChar *name);
00030 inline const char *getAttributeContent(xmlNodePtr elem, const char *name)
00031 {
00032 return (const char *)getAttributeContent(elem, (const xmlChar *)name);
00033 }
00034
00035 inline bool hasText(xmlNodePtr elem)
00036 {
00037 return (elem &&
00038 elem->children &&
00039 (elem->children->type == XML_TEXT_NODE) &&
00040 elem->children->content);
00041 }
00042
00043 inline const char *getText(xmlNodePtr elem)
00044 {
00045 if(hasText(elem))
00046 {
00047 return (const char *)elem->children->content;
00048 }
00049 return "";
00050 }
00051
00052 }
00053
00054 }
00055
00056 #endif // _XML_HELPER_H_