Opening / Creating a Document

All work with the xmlTree API starts with the document, whether you're using existing data or starting from scratch. There are three ways to obtain an xmlDoc object:

  • Reading an XML document from a file (xmlTreeNewDocFromFile(), here)

  • Reading an XML document from a string (xmlTreeNewDocFromString(), here)

  • Starting a new document (xmlTreeNewDoc(), here)


EXAMPLE

<$rawXml = "<simpleExample>read me</simpleExample>">
<$doc = (xmlTreeNewDocFromString($xmlRaw))>
<$root = (xmlTreeGetRootElement($doc))>
...
<$doc = (xmlTreeNewDocFromFile( 'sample.xml'))>
<$xpath= (xmlTreeNewXPath($doc))>
...
<$doc = (xmlTreeNewDoc( '1.0'))>
<$root = (xmlTreeNewElement($doc, 'rootNode'))>


SEE ALSO
xmlTreeNewDoc, xmlTreeNewDocFromFile, xmlTreeNewDocFromString


Copyright © Thunderstone Software     Last updated: Sep 25 2019
Copyright © 2019 Thunderstone Software LLC. All rights reserved.