CFX_XMLParser Tag Reference
CFX_XMLParser is a Java CFX tag for parsing XML docuemnts into WDDX packets representing structures. The WDDX packet is then turned into structures via CFWDDX.
All Attributes
Attribute Name |
Required |
Data Type |
Notes |
XML |
yes |
string |
A string of XML content |
OUTPUT |
no |
variable name |
The name of the output variable, default is wddxOutput |
FACTORYNAME |
no |
Class Name |
The JAXP document builder factory to use, the default is "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl". |
Examples
This example will parse the following...
<?xml version='1.0'?>
<root>
<person id='007'>
<firstname>James</firstname>
<lastname>Bond</lastname>
</person>
</root>
<cfset xml="<?xml version='1.0'?>
<root>
<person id='007'>
<firstname>James</firstname>
<lastname>Bond</lastname>
</person>
</root>
">
<CFX_XMLParser xml="#xml#" output="wddx">
<cfwddx action="WDDX2CFML" input="#wddx#" output="root">
<cfoutput>Agent #root.root.person.id# is #root.root.person.firstname.INNER_TEXT# #root.root.person.lastname.INNER_TEXT#</cfoutput>
Will output "Agent 007 is James Bond"
And the root structure will look like this
Note: using tags like CFDUMP, CF_DUMP, and CF_ObjectDump help you to visualize your XML documents structure. They can generate visualizations like the one above.
As you can see The tag will always generate a CHILD_LIST which will be a comma seperated list of child nodes at the current position.
This is useful when you have more than one tag with the same name at the same level, for instance multipe person tags would be treated as person, person2, person3, etc.
It also generates an ATTRIBUTE_LIST that shows all the attributes for a tag, and if a tag contains body text the INNER_TEXT value is set.
Install Instructions
CFX_XMLParser Install Instructions
If you are running Windows NT/2000 and CF4.5 or 5.0 (NOT CFMX OR ABOVE) you should run Setup.exe ON YOUR WEB SERVER
If you are running any Other Platform please follow the instructions below...
1) Read And agree to License.txt
2) Copy CFX_XMLParser.jar to CFUSION/Java/Classes
3) Get a JVM, If you have not done so already goto http://java.sun.com/products/ and download the Java 2 Standard Edition JRE (Java Runtime Environment), install it.
4) Log into your ColdFusion Administrator, click on "Java" from the menu on the left.
5) If there is not already a value (There shouldn't be unless you already installed it) Enter the path to your Java Virtual Machine "JVM". The default on windows is c:\program files\JavaSoft\JRE\1.3\bin\hotspot\jvm.dll or /usr/java/jdk1.3/hotspot/libjvm.so
If you cannot find the locations try:
Start -> Find -> jvm.dll (Windows)
$> find / | fgrep libjvm.so (UNIX)
6) In the classpath setting (Still in the Java Settings of CF Administrator) add the following value to the classpath
c:\cfusion\java\classes\CFX_XMLParser.jar;
If there are other values in this setting, seperate with a semi-colin (;) for windows, and with a colin (:) for UNIX.
Click "Apply"
10) Click on "CFX Tags" from the left menu. Enter in CFX_XMLParser in the text box, and select "Java" for tag type, click add.
11) Under Class Name put: CFX_XMLParser and enter a description, the supplied description is "Java Based XMLParser by CFDEV.COM"
Click "Apply"
12) Restart ColdFusion.
See: ColdFusion Java Setting for linux for additional linux help.
Copyright © CFDEV.COM 2001