View comments | RSS feed

XmlParse

Description

Converts an XML document that is represented as a string variable into an XML document object.

Return value

An XML document object.

Category

Conversion functions, Extensibility functions, XML functions

Syntax

XmlParse(xmlString [, caseSensitive ] )

See also

cfxml, IsXmlDoc, XmlChildPos, XmlChildPos, XmlFormat, XmlNew, XmlSearch, XmlTransform

History

New in ColdFusion MX: this function is new.

Parameters

Parameter Description
xmlString
An XML document object string
caseSensitive
  • yes: maintains the case of document elements and attributes
  • no. Default.

Usage

The caseSensitive attribute value determines whether identifiers whose characters are of varying case, but are otherwise the same, refer to different components. For example:

If the XML document is represented by a string variable, use the XmlParse tag directly on the variable. For example, if your application uses cfhttp action="get" to get the XML document, use the following code to create the XML document object:

<cfset myXMLDocument = XmlParse(cfhttp.fileContent)>

If the XML document is in a file, use the cffile tag to convert the file to a CFML variable, then use the XmlParse tag on the resulting variable. For example, if the XML document is in the file C:\temp\myxmldoc.xml, use the following code to convert the file to an XML document object:

<cffile action="read" file="C:\temp\myxmldoc.xml" variable="XMLFileText">
<cfset myXMLDocument=XmlParse(XMLFileText)>

Note:   If the file is not encoded with the ASCII or Latin-1 character set, use the cffile tag charset attribute to specify the file's character set. For example, if the file is encoded in UTF, specify charset="UTF-8".

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


cameroncf said on Sep 24, 2003 at 10:31 AM :
To convert an XML document object (struct) back into a string, use ToString().
No screen name said on Nov 19, 2004 at 6:12 AM :
Something I was just made painfully aware of (you know how hard it is to debug the very detailed NullPointer exception) is that if you parse a malformed XML, CFMX won't throw an error. My XMLSearch funcs were giving me NullPointers. Word to the wise: Use IsXmlDoc after XmlParse, because try/catch doesn't work in this situation!!
No screen name said on Nov 23, 2004 at 7:49 AM :
To clear up the above statement. It seems the problem arose from a file I got with an incorrectly formed 'doctype' tag.
No screen name said on Oct 7, 2006 at 9:58 AM :
This is helpful to see a quick view of your returned xml doc.
<cfdump var="#myXMLDocument#">
GWF said on Dec 11, 2006 at 11:04 AM :
XMLPares() will throw an error if the .XML contains the UTF-8 BOM. It should just ignore this.
halL said on Dec 11, 2006 at 1:04 PM :
A bug report has been submitted against the BOM issue reported by GWF.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt2122.htm