ColdFusion 9.0 Resources |
XmlGetNodeTypeReturnsA string identifying the XML node type. The following values are valid:
If the argument is not a document object node, the function generates an error. See alsoIsXmlAttribute, IsXmlDoc, IsXmlElem, IsXmlNode, IsXmlRoot, XmlChildPos, XmlValidate; Using XML and WDDX in the Developing ColdFusion Applications UsageThe XmlGetNodeType function can determine the types of the nodes returned by the XmlSearch function, or the types of the entries in an element’s XmlNodes array. ExampleThe following example checks the node types of various parts of an XML document object: <!--- Create an XML document object ---> <cfxml variable="xmlobject"> <?xml version="1.0" encoding="UTF-8"?> <order id="4323251"> <customer firstname="Philip" lastname="Cramer" accountNum="21"/> <items> <item id="43"> <!-- This item is coded to show several node types --> <![CDATA["Our Best" hammer & chisel set!!!]]> Imported from France <quantity>1</quantity> <unitprice>15.95</unitprice> </item> </items> </order> </cfxml> <!--- Display the node types ---> <cfoutput> <h3>Node Types</h3> xmlobject: #XMLGetNodeType(xmlobject)#<br> xmlobject.order: #XMLGetNodeType(xmlobject.order)#<br> <br> Now check the types of all the nodes in the xmlobject.order.items.item element's XmlNodes array.<br> Note the many apparently empty Text nodes generated by whitespace characters in the XML text source.<br><br> <cfset descnodes=xmlobject.order.items.item.XmlNodes> <cfloop from="1" to="#ArrayLen(descnodes)#" index="i"> #i# Node type is: #XMLGetNodeType(descnodes[i])#<br> #i# Node name is: #descnodes[i].XmlName#<br> <cfif (descnodes[#i#].XmlValue NEQ "")> #i# Node value is: #descnodes[i].XmlValue#<br> </cfif> <br> </cfloop> </cfoutput> |