X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=utils%2Fxmlgrep%2FREADME;h=33294ffbd19c639ade5cfd71396839fe802c2e64;hb=a89a28c4e62a63e05b6b889274fa848ea2bda007;hp=4a35d1d0c5d2f1af8cf85d0c6ed1b67550f2e54e;hpb=67ca3c0307c873d49327ac10f753049595e54afd;p=flightgear.git diff --git a/utils/xmlgrep/README b/utils/xmlgrep/README index 4a35d1d0c..33294ffbd 100644 --- a/utils/xmlgrep/README +++ b/utils/xmlgrep/README @@ -7,8 +7,8 @@ the memory footprint can be kept low and the library can be kept simple. To achieve these goals the mmap function is used to map the configuration file to a memory region. The only places where memory is allocated is when creating -a new XML-id, when requesting a string from a node or when a request is made to -copy a node. +a new XML-id, when requesting a string from a node, when requestiong the node +name or when a request is made to copy a node into a new memory region. Using this library should be pretty simple for most tasks; just open a file, read every parameter one by one and close the id again. @@ -16,25 +16,24 @@ read every parameter one by one and close the id again. void *xid; xid = xmlOpen("/tmp/file.xml"); - xpos = xmlGetNodeDouble(xid, "/configuration/x-pos"); - ypos = xmlGetNodeDouble(xid, "/configuration/y-pos"); - zpos = xmlGetNodeDouble(xid, "/configuration/z-pos"); + xpos = xmlNodeGetDouble(xid, "/configuration/x-pos"); + ypos = xmlNodeGetDouble(xid, "/configuration/y-pos"); + zpos = xmlNodeGetDouble(xid, "/configuration/z-pos"); xmlClose(xid); } While it is certainly possible to access every node directly by calling the -xmlGetNode(Int/Double/String) functions, when more than one node need to be +xmlNodeGet(Int/Double/String) functions, when more than one node need to be gathered from a parent node it is advised to get the id of the parent node -and work from there. This is because the XML-id holds the boundaries of the -(parent)node which limits the searching area resulting in improved searching -speed. +and work from there since the XML-id holds the boundaries of the (parent)node +which limits the searching area resulting in improved searching speed. { void *xnid; char *s; - xnid = xmlGetNode(id, "/configuration/setup/"); - version = xmlGetNodeDouble(xnid, "version"); - s = xmlGetNodeString(xnid, "author"); + xnid = xmlNodeGet(id, "/configuration/setup/"); + version = xmlNodeGetDouble(xnid, "version"); + s = xmlNodeGetString(xnid, "author"); if (s) author = s; free(s); free(xnid); @@ -48,24 +47,25 @@ Overview of the available functions: # id = xmlOpen("/tmp/file.xml"); # xmlClose(id); # -void *xmlOpen(const char *); -void xmlClose(const void *); +void *xmlOpen(const char *filename); +void *xmlInitBuffer(const char *buffer, size_t size); +void xmlClose(void *xid); # # Get the Id of a node at the specified path # e.g. -# xnid = xmlGetNode(id, "/path/to/specified/node"); +# xnid = xmlNodeGet(id, "/path/to/specified/node"); # -void *xmlGetNode(const void *, const char *); -void *xmlCopyNode(void *, const char *); +void *xmlNodeGet(const void *xid, const char *path); +void *xmlNodeCopy(const void *xid, const char *path); # # Functions to walk the node tree and process them one by one. # e.g. # xmid = xmlMarkId(id); -# num = xmlGetNumElements(xmid); +# num = xmlNodeGetNum(xmid, "node"); # for (i=0; i