Example of custom Input/Output
Demonstrate the use of xmlRegisterInputCallbacks to build a custom I/O layer, this is used in an XInclude method context to show how dynamic document can be built in a clean way.
io1
io1 > io1.tmp ; diff io1.tmp io1.res ; rm -f io1.tmp
Daniel Veillard
see Copyright for the status of this software.
<libxml/parser.h>
<libxml/xinclude.h>
<libxml/tree.h>
<libxml/xmlIO.h>
Parse an XML file to a tree and free it
Demonstrate the use of xmlReadFile() to read an XML file into a tree and and xmlFreeDoc() to free the resulting tree
parse1 test1.xml
parse1 test1.xml
Daniel Veillard
see Copyright for the status of this software.
<libxml/tree.h>
<libxml/parser.h>
Parse and validate an XML file to a tree and free the result
Create a parser context for an XML file, then parse and validate the file, creating a tree, check the validation result and xmlFreeDoc() to free the resulting tree.
parse2 test2.xml
parse2 test2.xml
Daniel Veillard
see Copyright for the status of this software.
<libxml/tree.h>
<libxml/parser.h>
Parse an XML file with an xmlReader
Demonstrate the use of xmlReaderForFile() to parse an XML file and dump the informations about the nodes found in the process. (Note that the XMLReader functions require libxml2 version later than 2.6.)
reader1 <filename>
reader1 test2.xml > reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp
Daniel Veillard
see Copyright for the status of this software.
<libxml/xmlreader.h>
Parse and validate an XML file with an xmlReader
Demonstrate the use of xmlReaderForFile() to parse an XML file validating the content in the process and activating options like entities substitution, and DTD attributes defaulting. (Note that the XMLReader functions require libxml2 version later than 2.6.)
reader2 <valid_xml_filename>
reader2 test2.xml > reader1.tmp ; diff reader1.tmp reader1.res ; rm reader1.tmp
Daniel Veillard
see Copyright for the status of this software.
<libxml/xmlreader.h>
Show how to extract subdocuments with xmlReader
Demonstrate the use of xmlTextReaderPreservePattern() to parse an XML file with the xmlReader while collecting only some subparts of the document. (Note that the XMLReader functions require libxml2 version later than 2.6.)
reader3
reader3 > reader3.tmp ; diff reader3.tmp reader3.res ; rm reader3.tmp
Daniel Veillard
see Copyright for the status of this software.
<libxml/xmlreader.h>
use various APIs for the xmlWriter
tests a number of APIs for the xmlWriter, especially the various methods to write to a filename, to a memory buffer, to a new document, or to a subtree. It shows how to do encoding string conversions too. The resulting documents are then serialized.
testWriter
testWriter ; for i in 1 2 3 4 ; do diff writer.xml writer$$i.res ; done ; rm writer*.res
Alfred Mickautsch
see Copyright for the status of this software.
<libxml/encoding.h>
<libxml/xmlwriter.h>
Navigates a tree to print element names
Parse a file to a tree, use xmlDocGetRootElement() to get the root element, then walk the document and print all the element name in document order.
tree1 filename_or_URL
tree1 test2.xml > tree1.tmp ; diff tree1.tmp tree1.res ; rm tree1.tmp
Dodji Seketeli
see Copyright for the status of this software.
<libxml/tree.h>
<libxml/parser.h>
Creates a tree
Shows how to create document, nodes and dump it to stdout or file.
tree2 <filename> -Default output: stdout
tree2 > tree2.tmp ; diff tree2.tmp tree2.res ; rm tree2.tmp
Lucas Brasilino <brasilino@recife.pe.gov.br>
see Copyright for the status of this software
<libxml/tree.h>
<libxml/parser.h>
Evaluate XPath expression and prints result node set.
Shows how to evaluate XPath expression and register known namespaces in XPath context.
xpath1 <xml-file> <xpath-expr> [<known-ns-list>]
Aleksey Sanin
see Copyright for the status of this software.
<libxml/xpath.h>
<libxml/parser.h>
<libxml/xpathInternals.h>
<libxml/tree.h>