ZEDA  1.6.18
zeda_xml.h
Go to the documentation of this file.
1 /* ZEDA - Elementary Data and Algorithms
2  * Copyright (C) 1998 Tomomichi Sugihara (Zhidao)
3  */
9 #ifndef __ZEDA_XML_H__
10 #define __ZEDA_XML_H__
11 
12 #ifndef __KERNEL__
13 
14 #include <zeda/zeda_misc.h>
15 #include <libxml/parser.h>
16 
18 
19 /* check if the compiled and linked versions match. */
20 #define zXMLInit() LIBXML_TEST_VERSION
21 
22 /* strings */
23 
24 #define zXMLCheckStr(str1,str2) ( strcmp( (char*)(str1), (str2) ) == 0 )
25 
26 #define zXMLGetString(node) ( (char *)xmlNodeListGetString( (node)->doc, node, 1 ) )
27 #define zXMLGetInt(node) atoi( zXMLGetString( node ) )
28 #define zXMLGetContent(node) ( (char *)xmlNodeGetContent( node ) )
29 
30 /* nodes & elements */
31 
32 #define zXMLForEachNode(node,np) \
33  for( (np)=(node); (np); (np)=(np)->next )
34 
35 #define zXMLCheckElement(node,str) \
36  ( (node)->type == XML_ELEMENT_NODE && zXMLCheckStr( (node)->name, str ) )
37 
38 #define zXMLCheckElementAndExec(node,name,op) \
39  if( zXMLCheckElement(node,name) ){ if( !op ) return false; }
40 
41 __EXPORT xmlNode *zXMLFindNodeElement(xmlNode *node, char *name);
42 #define zXMLFindNodeAttr(node,name) ( (char *)xmlGetProp( node, (xmlChar*)name ) )
43 #define zXMLAddNodeAttr(node,name,val) xmlNewProp( node, (xmlChar *)name, (xmlChar *)val )
44 #define zXMLReplaceNodeAttr(node,name,val) xmlSetProp( node, (xmlChar *)name, (xmlChar *)val )
45 
46 /* attributes */
47 
48 #define zXMLGetAttrVal(attr) ( (char *)xmlNodeListGetString( (attr)->doc, (attr)->children, 1 ) )
49 #define zXMLGetAttrInt(attr) atoi( zXMLGetAttrVal( attr ) )
50 #define zXMLGetAttrDouble(attr) atof( zXMLGetAttrVal( attr ) )
51 
52 #define zXMLForEachAttr(node,attr) \
53  for( (attr)=(node)->properties; (attr); (attr)=(attr)->next )
54 
55 #define zXMLCheckAttr(attr,str) zXMLCheckStr( (attr)->name, str )
56 
57 #define zXMLCheckAttrAndExec(attr,str,op) \
58  if( zXMLCheckStr( (attr)->name, str ) ){ (op); }
59 
60 __EXPORT bool zXMLCheckAttrVal(xmlAttr *attr, char *name, char *str);
61 
63 
64 #endif /* __KERNEL__ */
65 
66 #endif /* __ZEDA_XML_H__ */
bool zXMLCheckAttrVal(xmlAttr *attr, char *name, char *str)
#define __END_DECLS
Definition: zeda_defs.h:30
miscellanies.
xmlNode * zXMLFindNodeElement(xmlNode *node, char *name)
#define __BEGIN_DECLS
Definition: zeda_defs.h:26
#define __EXPORT
Definition: zeda_compat.h:32