Better XML

PDF HTML FlashPaper

Special: Categories | Getting Started

(Redirected from Special.Categories.General)

The first thing to understand is that an instance of the betterXml component is needed for each XML file / string that you need and each instance will be associated with Xml data. These components are not merely collections of udfs.

The components both have an init method for instantiation so, using CreateObject, we can get an instance of the betterXmlEditor, loading it with the xml file 'myXmlFile', with the following code:

variables.myXmlFile = ExpandPath('someXmlFile.xml'); variables.oXmlInstance = CreateObject('component', 'betterXmlEditor').init(myXmlFile);

Some hosts do not allow access to CreateObject() so cfinvoke can be used instead:

<cfset variables.myXmlFile = ExpandPath('someXmlFile.xml')> <cfinvoke component="betterXmlEditor" method="init" src="#myXmlFile#" returnvariable="variables.oXmlInstance"/>

Either way, we now have the variable oXmlInstance which is an instance of the betterXmlEditor component and loaded with the xml file, 'someXmlFile.xml' (I use the 'o' prefix to denote a custom object). We can now invoke the component methods which will work directly on the loaded xml; for example, the search method:

variables.aResults = oXmlInstance.Search('/my/xpath/search');

Note: an xml string or URL that returns xml can be used in place of the file.


Pages in category "Getting Started"

There are 0 pages in this category.