kstars
XML Functions: Functions to parse, process, and search XML.
Functions | |
| XMLAtt * | addXMLAtt (XMLEle *ep, const char *name, const char *value) |
| XMLEle * | addXMLEle (XMLEle *parent, const char *tag) |
| void | delLilXML (LilXML *lp) |
| void | delXMLEle (XMLEle *e) |
| void | editXMLAtt (XMLAtt *ap, const char *str) |
| void | editXMLEle (XMLEle *ep, const char *pcdata) |
| char * | entityXML (char *str) |
| XMLAtt * | findXMLAtt (XMLEle *e, const char *name) |
| const char * | findXMLAttValu (XMLEle *ep, const char *name) |
| XMLEle * | findXMLEle (XMLEle *e, const char *tag) |
| void | indi_xmlMalloc (void *(*newmalloc)(size_t size), void *(*newrealloc)(void *ptr, size_t size), void(*newfree)(void *ptr)) |
| char * | nameXMLAtt (XMLAtt *ap) |
| LilXML * | newLilXML (void) |
| XMLAtt * | nextXMLAtt (XMLEle *ep, int first) |
| XMLEle * | nextXMLEle (XMLEle *ep, int first) |
| int | nXMLAtt (XMLEle *ep) |
| int | nXMLEle (XMLEle *ep) |
| XMLEle * | parentXMLAtt (XMLAtt *ap) |
| XMLEle * | parentXMLEle (XMLEle *ep) |
| int | pcdatalenXMLEle (XMLEle *ep) |
| char * | pcdataXMLEle (XMLEle *ep) |
| void | prXMLEle (FILE *fp, XMLEle *e, int level) |
| XMLEle * | readXMLEle (LilXML *lp, int c, char errmsg[]) |
| XMLEle * | readXMLFile (FILE *fp, LilXML *lp, char errmsg[]) |
| void | rmXMLAtt (XMLEle *ep, const char *name) |
| int | sprlXMLEle (XMLEle *ep, int level) |
| int | sprXMLEle (char *s, XMLEle *ep, int level) |
| char * | tagXMLEle (XMLEle *ep) |
| char * | valuXMLAtt (XMLAtt *ap) |
Function Documentation
Add an XML attribute to an existing XML element.
- Parameters:
-
ep pointer to an XML element name the name of the XML attribute to add. value the value of the XML attribute to add.
add an element with the given tag to the given element.
parent can be NULL to make a new root.
- Returns:
- if parent is NULL, a new root is returned, otherwise, parent is returned.
| void delLilXML | ( | LilXML * | lp | ) |
Delete a lilxml parser.
- Parameters:
-
lp a pointer to a lilxml parser to be deleted.
| void delXMLEle | ( | XMLEle * | e | ) |
Delete an XML element.
- Returns:
- a pointer to the XML Element to be deleted.
| void editXMLAtt | ( | XMLAtt * | ap, | |
| const char * | str | |||
| ) |
change the value of an attribute to str.
- Parameters:
-
ap pointer to XML attribute str new attribute value
| void editXMLEle | ( | XMLEle * | ep, | |
| const char * | pcdata | |||
| ) |
set the pcdata of the given element
- Parameters:
-
ep pointer to an XML element. pcdata pcdata to set.
| char* entityXML | ( | char * | str | ) |
return a string with all xml-sensitive characters within the passed string replaced with their entity sequence equivalents.
N.B. caller must use the returned string before calling us again.
Find an XML attribute within an XML element.
- Parameters:
-
e a pointer to the XML element to search. name the attribute name to search for.
- Returns:
- A pointer to the XML attribute if found or NULL on failure.
| const char* findXMLAttValu | ( | XMLEle * | ep, | |
| const char * | name | |||
| ) |
Find an XML element's attribute value.
- Parameters:
-
ep a pointer to an XML element. name the name of the XML attribute to retrieve its value.
- Returns:
- the value string of an XML element on success. NULL on failure.
Find an XML element within an XML element.
- Parameters:
-
e a pointer to the XML element to search. tag the element tag to search for.
- Returns:
- A pointer to the XML element if found or NULL on failure.
| void indi_xmlMalloc | ( | void *(*)(size_t size) | newmalloc, | |
| void *(*)(void *ptr, size_t size) | newrealloc, | |||
| void(*)(void *ptr) | newfree | |||
| ) |
| char* nameXMLAtt | ( | XMLAtt * | ap | ) |
Return the name of an XML attribute.
- Parameters:
-
ap a pointer to an XML attribute.
- Returns:
- the name string of the attribute.
| LilXML* newLilXML | ( | void | ) |
Create a new lilxml parser.
- Returns:
- a pointer to the lilxml parser on success. NULL on failure.
Iterate an XML element for a list of XML attributes.
- Parameters:
-
ep a pointer to the XML element to iterate. first the index of the starting XML attribute. Pass 1 to start iteration from the beginning of the XML element. Pass 0 to get the next attribute thereater.
- Returns:
- On success, a pointer to the next XML attribute is returned. NULL when there are no more attributes.
Iterate an XML element for a list of nesetd XML elements.
- Parameters:
-
ep a pointer to the XML element to iterate. first the index of the starting XML element. Pass 1 to start iteration from the beginning of the XML element. Pass 0 to get the next element thereater.
- Returns:
- On success, a pointer to the next XML element is returned. NULL when there are no more elements.
| int nXMLAtt | ( | XMLEle * | ep | ) |
Return the number of XML attributes in a parent XML element.
- Parameters:
-
ep a pointer to an XML element.
- Returns:
- the number of XML attributes within the XML element.
| int nXMLEle | ( | XMLEle * | ep | ) |
Return the number of nested XML elements in a parent XML element.
- Parameters:
-
ep a pointer to an XML element.
- Returns:
- the number of nested XML elements.
Return the parent of an XML attribute.
- Returns:
- a pointer to the XML element parent.
Return the parent of an XML element.
- Returns:
- a pointer to the XML element parent.
| int pcdatalenXMLEle | ( | XMLEle * | ep | ) |
Return the number of characters in pcdata in an XML element.
- Parameters:
-
ep a pointer to an XML element.
- Returns:
- the length of the pcdata string.
| char* pcdataXMLEle | ( | XMLEle * | ep | ) |
Return the pcdata of an XML element.
- Parameters:
-
ep a pointer to an XML element.
- Returns:
- the pcdata string on success.
| void prXMLEle | ( | FILE * | fp, | |
| XMLEle * | e, | |||
| int | level | |||
| ) |
Print an XML element.
- Parameters:
-
fp a pointer to FILE where the print output is directed. e the XML element to print. level the printing level, set to 0 to print the whole element.
Process an XML one char at a time.
- Parameters:
-
lp a pointer to a lilxml parser. c one character to process. errmsg a buffer to store error messages if an error in parsing is encounterd.
- Returns:
- When the function parses a complete valid XML element, it will return a pointer to the XML element. A NULL is returned when parsing the element is still in progress, or if a parsing error occurs. Check errmsg for errors if NULL is returned.
Handy wrapper to read one xml file.
- Parameters:
-
fp pointer to FILE to read. lp pointer to lilxml parser. errmsg a buffer to store error messages on failure.
- Returns:
- root element else NULL with report in errmsg[].
| void rmXMLAtt | ( | XMLEle * | ep, | |
| const char * | name | |||
| ) |
Remove an XML attribute from an XML element.
- Parameters:
-
ep pointer to an XML element. name the name of the XML attribute to remove
| int sprlXMLEle | ( | XMLEle * | ep, | |
| int | level | |||
| ) |
return number of bytes in a string guaranteed able to hold result of sprXLMEle(ep) (sans trailing ).
N.B. set level = 0 on first call.
| int 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. N.B. set level = 0 on first call.
- Returns:
- return length of resulting string (sans trailing )
| char* tagXMLEle | ( | XMLEle * | ep | ) |
Return the tag of an XML element.
- Parameters:
-
ep a pointer to an XML element.
- Returns:
- the tag string.
| char* valuXMLAtt | ( | XMLAtt * | ap | ) |
Return the value of an XML attribute.
- Parameters:
-
ap a pointer to an XML attribute.
- Returns:
- the value string of the attribute.
KDE 4.2 API Reference