Whatever message this page gives is out now! Go check it out!
XmlParse(xmlText [, caseSensitive ], validator])| Parameter | Description |
xmlText | Any of the following:
|
caseSensitive |
|
validator | Any of the following:
|
| parseroptions | To disable XXE and other attacks, use the following attributes:
See the example at the end. |
MyDoc.xmlRoot.XmlAttributes["Version"] = "12b";
MyDoc.xmlRoot.XmlAttributes.Version = "12b";
MyDoc.MyRoot.XmlAttributes["Version"] = "12b";XmlParse() rejects XML input that contains a <!DOCTYPE ...> declaration unless you explicitly opt in by setting parserOptions.ALLOWDOCTYPEDECLARATION = true.parserOptions struct with ALLOWDOCTYPEDECLARATION=true.ALLOWDOCTYPEDECLARATION=false together with ALLOWEXTERNALENTITIES=false and a suitable ENTITYEXPANSIONLIMIT.<!--- Old behavior: XML containing DOCTYPE could be parsed without an explicit opt-in --->
<cfset doc = XmlParse(myXmlString)>
<!--- New behavior: explicitly allow DOCTYPE only for trusted XML --->
<cfset opts = {
ALLOWDOCTYPEDECLARATION = true,
ALLOWEXTERNALENTITIES = false,
ENTITYEXPANSIONLIMIT = 1000
}>
<cfset doc = XmlParse(myXmlString, false, opts)><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE order SYSTEM "C:\ColdFusion\wwwroot\examples\custorder.dtd">
<order id="4323251">
<customer firstname="Philip" lastname="Cramer" accountNum="21"/>
<items>
<item id="43">
<name> Deluxe Carpenter's Hammer</name>
<quantity>1</quantity>
<unitprice>15.95</unitprice>
</item>
<item id="54">
<name> 36" Plastic Rake</name>
<quantity>2</quantity>
<unitprice>6.95</unitprice>
</item>
<item id="68">
<name> Standard paint thinner</name>
<quantity>3</quantity>
<unitprice>8.95</unitprice>
</item>
</items>
</order><!ELEMENT order (customer, items)>
<!ATTLIST order
id CDATA #REQUIRED>
<!ELEMENT customer EMPTY>
<!ATTLIST customer
firstname CDATA #REQUIRED
lastname CDATA #REQUIRED
accountNum CDATA #REQUIRED>
<!ELEMENT items (item+)>
<!ELEMENT item (name, quantity, unitprice)>
<!ATTLIST item
id CDATA #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT unitprice (#PCDATA)><cfset
myDoc=XMLParse("C:\ColdFusion\wwwroot\examples\custorder.xml",
false, "http://localhost:8500/examples/custorder.dtd")>
Dump of myDoc XML document object<br>
<cfdump var="#myDoc#"><cfset parseroptions = structnew()>
<!--- Prevent XML External Entity (XXE) vulnerabilities --->
<cfset parseroptions.ALLOWEXTERNALENTITIES = false>
<cfset parseroptions. ENTITYEXPANSIONLIMIT=64000>
<cfscript>
a = XmlParse("file.xml", false, parseroptions);
writeDump(a);
</cfscript>