Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@SamG is correct that ColdFusion XML parsing can't do it because of the DOM parser, but SAX is painful, instead use a StAX parser, which provides a much simpler iterator interface. <a href="https://stackoverflow.com/questions/4566059/xslt-conversion-creating-new-qnames-from-elements/4572094#4572094">See the answer to another question I provided for an example of how to do this with ColdFusion</a>.</p> <p>This is roughly what you'd do for your example: </p> <pre><code>&lt;cfset fis = createObject("java", "java.io.FileInputStream").init( "#getDirectoryFromPath(getCurrentTemplatePath())#/file.xml" )&gt; &lt;cfset bis = createObject("java", "java.io.BufferedInputStream").init(fis)&gt; &lt;cfset XMLInputFactory = createObject("java", "javax.xml.stream.XMLInputFactory").newInstance()&gt; &lt;cfset reader = XMLInputFactory.createXMLStreamReader(bis)&gt; &lt;cfloop condition="#reader.hasNext()#"&gt; &lt;cfset event = reader.next()&gt; &lt;cfif event EQ reader.START_ELEMENT&gt; &lt;cfswitch expression="#reader.getLocalName()#"&gt; &lt;cfcase value="advs"&gt; &lt;!--- root node, do nothing ---&gt; &lt;/cfcase&gt; &lt;cfcase value="advuser"&gt; &lt;!--- set values used later on for inserts, selects, updates ---&gt; &lt;/cfcase&gt; &lt;cfcase value="user"&gt; &lt;!--- some selects and insert ---&gt; &lt;/cfcase&gt; &lt;cfcase value="vehicle"&gt; &lt;!--- insert or update ---&gt; &lt;/cfcase&gt; &lt;/cfswitch&gt; &lt;/cfif&gt; &lt;/cfloop&gt; &lt;cfset reader.close()&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload