CF_XMLParser Tag Reference (ColdFusion Wrapper Tag)
CF_XMLParser ColdFusion CustomTag wrapper for CFX_XMLParser.
All Attributes
Attribute Name |
Required |
Data Type |
Notes |
XML |
no |
string |
A string of XML content |
FILE |
no |
server path |
A file on the server that contains an xml document. |
URL |
no |
url |
A url that contains an XML document. |
OUTPUT |
no |
variable name |
The name of the output variable, default is root. Outputs a structure. |
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>
">
<CF_XMLParser xml="#xml#" 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
Copy xmlparser.cfm to CustomTags directory, or put in same directory you called it from. This tag requires that CFX_XMLParser is installed.