Functions to support XML nodes.XMLNode currently supported only by individualization placeholders.
static XMLNode root(XMLTree tree)
Get the root element of an XML tree.
Name | Type | Default | Description |
Return | XMLNode | Root element of the given XML tree 0 : Error |
|
tree | XMLTree | tree | XML tree opened with xmlquery::open |
Run through a complete XML tree and write it to the log.
#include "internal/types.h"
int wnode (XMLNode nd, int depth) { int i; int type; char * content = 0;
// Sanity check // if (!nd) return 0;
// Write name // for (i = 0; i < depth; i++) wlog ("", "\t"); if (xmlnode::is_attribute (nd)) wlog ("", "%s = ", xmlnode::name (nd)); else wlog ("", "<%s> ", xmlnode::name (nd));
// Write content // content = xmlnode::content (nd); if (xmlnode::is_attribute (nd) || (content && *content)) { wlog ("", "\"%s\"", content); }
wlog ("", "\n"); return 0; }
int show_nodes (XMLNode * parent, int depth) { int i; XMLNode nd;
if (!parent) return 0;
wnode (parent, depth); for (i = 0; i < xmlnode::children (parent); i++) { nd = xmlnode::child (parent, i);
show_nodes (nd, depth + 1); // Recursive dive }
return 0; }
int main () { XMLTree t = xmlquery::open ("/Users/paul/Desktop/test.xml");
show_nodes (xmlnode::root (t), 0); xmlquery::close (t); return 0; }
static int children(XMLNode node)
Number of direct children and attributes of a given XML node.
Name | Type | Default | Description |
Return | int | Number of direct sub elements and attributes | |
node | XMLNode | - | Valid XML node |
static XMLNode child(XMLNode node, int nth)
Number of direct children and attributes of a given XML node.
Name | Type | Default | Description |
Return | XMLNode | nth direct sub element 0 : error no more elements |
|
node | XMLNode | - | Valid XML node |
nth | int | - | 0-based index of element |
static int type(XMLNode node)
Type of an given XML element.
Name | Type | Default | Description |
Return | int | Type of element -1 : Error 0 : Normal 1 : Content 2 : Entity reference 3 : Processing instruction 4 : Comment |
|
node | XMLNode | - | valid XML node |
static char* content(XMLNode node)
Text content of an XML node.
Name | Type | Default | Description |
Return | char* | Text content of the sub node. "" : in case of errors The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values. |
|
node | XMLNode | - | valid XML node |
static char* content_of_child(XMLNode node, char* child_name)
Text content of an XML sub node or attribute.
Name | Type | Default | Description |
Return | char* | Text content of an XML sub node or attribute "" : in case of errors The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values. |
|
node | XMLNode | - | Valid XML node |
child_name | String or char* | - | Name of the child to query |
For an individalization of o document, an XML file is used. The text given in the node email should be shown as QR code.
int main () { char to [512];
strcpy (to, xmlnode::content_of_child (gData, "email")); if (strlen (to)) image::barcode (gFrame, to, "qrcode", 72, 72, 10, 10); return 0; }
static char* name(XMLNode node)
Name of an XML node
Name | Type | Default | Description |
Return | char* | Name of XML node "" : in case of errors The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values. |
|
node | XMLNode | - | valid XML node |
static char* path(XMLNode node)
Path to an XML node
Name | Type | Default | Description |
Return | char* | Path to the XML node "" : in case of errors The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. See here to learn more about functions returning r/o char* values. |
|
node | XMLNode | - | valid XML node |
static int is_attribute(XMLNode node)
Is the node defined as an attribute in the original tree?
Name | Type | Default | Description |
Return | int | 1 : Yes, the node is defined as an attribute. 0 : No, the node is an element |
|
node | XMLNode | - | Valid XML node |
Alphabetic index HTML hierarchy of classes or Java