3Copyright (C) 2003 Elwood C. Downey
6This library is free software;
7you can redistribute it and / or
8modify it under the terms of the GNU Lesser General Public
9License as published by the Free Software Foundation;
11version 2.1 of the License, or (at your option) any later version.
13This library is distributed in the hope that it will be useful,
14 but WITHOUT
ANY WARRANTY;
15without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17Lesser General Public License
for more details.
19You should have received a copy of the GNU Lesser General Public
20License along with
this library;
21if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA
73#define XML_ERROR_SIZE 1024
308extern void indi_xmlMalloc(
void *(*newmalloc)(
size_t size),
void *(*newrealloc)(
void *ptr,
size_t size),
309 void (*newfree)(
void *ptr));
const char * findXMLAttValu(XMLEle *ep, const char *name)
Find an XML element's attribute value.
XMLEle * cloneXMLEle(XMLEle *ep, int(*replace)(void *self, XMLEle *source, XMLEle **replace), void *self)
clone (deep) a xmlEle. Optional replacement function can be passed, to replace a whole subtree instea...
XMLEle * parentXMLEle(XMLEle *ep)
Return the parent of an XML element.
int nXMLEle(XMLEle *ep)
Return the number of nested XML elements in a parent XML element.
XMLEle * readXMLEle(LilXML *lp, int c, char errmsg[])
Process an XML one char at a time.
XMLEle * nextXMLEle(XMLEle *ep, int first)
Iterate an XML element for a list of nesetd XML elements.
LilXML * newLilXML()
Create a new lilxml parser.
XMLEle ** parseXMLChunk(LilXML *lp, char *buf, int size, char errmsg[])
Process an XML chunk.
size_t sprXMLCDataOffset(XMLEle *root, XMLEle *child, int level)
return exact position of cdata of child in printed representation of root N.B. set level = 0 on first...
int nXMLAtt(XMLEle *ep)
Return the number of XML attributes in a parent XML element.
char * tagXMLEle(XMLEle *ep)
Return the tag of an XML element.
char * nameXMLAtt(XMLAtt *ap)
Return the name of an XML attribute.
XMLEle * addXMLEle(XMLEle *parent, const char *tag)
add an element with the given tag to the given element. parent can be NULL to make a new root.
size_t sprXMLEle(char *s, XMLEle *ep, int level)
sample print ep to string s. N.B. s must be at least as large as that reported by sprlXMLEle()+1....
XMLAtt * findXMLAtt(XMLEle *e, const char *name)
Find an XML attribute within an XML element.
void prXMLEle(FILE *fp, XMLEle *e, int level)
Print an XML element.
XMLEle * parentXMLAtt(XMLAtt *ap)
Return the parent of an XML attribute.
XMLAtt * nextXMLAtt(XMLEle *ep, int first)
Iterate an XML element for a list of XML attributes.
char * entityXML(char *str)
return a string with all xml-sensitive characters within the passed string replaced with their entity...
char * valuXMLAtt(XMLAtt *ap)
Return the value of an XML attribute.
void editXMLEle(XMLEle *ep, const char *pcdata)
set the pcdata of the given element
XMLEle * setXMLEleTag(XMLEle *ep, const char *tag)
Update the tag of an element.
void rmXMLAtt(XMLEle *ep, const char *name)
Remove an XML attribute from an XML element.
XMLEle * findXMLEle(XMLEle *e, const char *tag)
Find an XML element within an XML element.
size_t sprlXMLEle(XMLEle *ep, int level)
return number of bytes in a string guaranteed able to hold result of sprXLMEle(ep) (sans trailing \0@...
void indi_xmlMalloc(void *(*newmalloc)(size_t size), void *(*newrealloc)(void *ptr, size_t size), void(*newfree)(void *ptr))
void delXMLEle(XMLEle *e)
delXMLEle Delete XML element.
char * pcdataXMLEle(XMLEle *ep)
Return the pcdata of an XML element.
void editXMLAtt(XMLAtt *ap, const char *str)
change the value of an attribute to str.
void delLilXML(LilXML *lp)
Delete a lilxml parser.
XMLEle * shallowCloneXMLEle(XMLEle *ele)
return a surface copy of a node. Don't copy childs or cdata.
XMLEle * readXMLFile(FILE *fp, LilXML *lp, char errmsg[])
Handy wrapper to read one xml file.
int pcdatalenXMLEle(XMLEle *ep)
Return the number of characters in pcdata in an XML element.
XMLAtt * addXMLAtt(XMLEle *ep, const char *name, const char *value)
Add an XML attribute to an existing XML element.