XmlValidate()
Uses a Document Type Definition (DTD) or XML Schema to validate an XML text document or an XML document object.
XmlValidate( xmlDoc=string, validator=any );
Returns: Struct
Examples
validator = "
<?xml version=""1.0""?>
<xs:schema xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
<xs:element name=""note"">
<xs:complexType>
<xs:sequence>
<xs:element name=""to"" type=""xs:string""/>
<xs:element name=""from"" type=""xs:string""/>
<xs:element name=""heading"" type=""xs:string""/>
<xs:element name=""body"" type=""xs:string""/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
";
<span class="nv">xml_stream</span> <span class="o">=</span> <span class="s2">"</span>
<?xml version=""1.0"" encoding=""UTF-8""?>
<note>
<to>Alice</to>
<from>Bob</from>
<heading>Reminder</heading>
<body>Here is the message you requested.</body>
</note>";
<span class="nv">xml_document</span> <span class="o">=</span> <span class="nf">XmlParse</span><span class="p">(</span><span class="nv">xml_stream</span><span class="p">);</span>
<span class="nf">dump</span><span class="p">(</span><span class="nf">xmlValidate</span><span class="p">(</span><span class="nv">xml_document</span><span class="p">,</span> <span class="nv">validator</span><span class="p">));</span>
See also
- XML
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)