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)


<$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'))>

xmlTreeNewDoc, xmlTreeNewDocFromFile, xmlTreeNewDocFromString

Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.