Marc-
Thanks you very much for the code snippets.  This is helping me get my arms around how 
go about manipulating xml.

Tom

-----Original Message-----
From: Marc Esher [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 8:34 PM
To: [EMAIL PROTECTED]
Subject: RE: [cf-xml] xml - cf question


I've been using the latest MSXML parser (4.0) without any troubles, either.
the documentation is pretty good, too. It's a quick install, although you
might need to download the newest MS installer before you can install the
parser (sounds complicated....it's not).

Go to this link (watch the wrap in outlook), download the installer and
msxml4.0 parser.
http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?ur
l=/msdn-files/027/001/766/msdncompositedoc.xml


Then take a look at some of the attached code to get you started. Know that
I pretty much stole this code from the macromedia coldfusion forums and
adapted it to suit my needs.

<cfloop query="myDirectory">
  <!--- read the files into a variable   --->
  <cffile action="READ"
 file="SomeFile.xml"
 variable="xmlContent">
  <cfset xmlContent =ReReplace(xmlContent ,"<!DOCTYPE[^>]+>","")>

  <!--- Create COM Object to parse the xml file  --->
  <CFOBJECT action="CREATE" type="COM" class="Microsoft.XMLDOM"
name="objXML">
<!--- note: to use msxml 4.0, you'll change the class to
Microsoft.XMLDOM4.0, or something like that...it's in the docs for the
parser --->


  <cfset objXML.LOADXML(#xmlContent#)>
  <cfset objXML.async = false>
  <cfset ElementList = objXML.getElementsByTagName("metadata")>

  <!--- get the data from the xml file --->
    <cfloop collection="#ElementList#" Item="metadata">
      <!--- get articleinfo data --->
      <cfset journaltitle =
metadata.SelectSingleNode("articleinfo/journal-title")>
      <cfset articletitle =
metadata.SelectSingleNode("articleinfo/article-title")>
      <cfset shorttitle =
metadata.SelectSingleNode("articleinfo/short-title")>
        <cfset manuscriptno =
metadata.SelectSingleNode("articleinfo/manuscript-number")>
    </cfloop>

<!--- To display the content of the variable, you have to use
variablename.text, like the following --->

    <cfoutput>
      <!--- show filename --->
      <p><strong>FILE:</strong> #name# (The update was #isUpdated#)</p>
      <!--- show articleinfo data --->
      <strong>Journal:</strong> #journaltitle.text#<br>
      <strong>Title:</strong> #articletitle.text#<br>
        <strong>Ms. number:</strong> #manuscriptno.text#<br>
    </cfoutput>

NOTE: It might be quicker to use cfscript/createObject() to instantiate the
msxml object and set the variables, but I haven't tried so I don't know.

I'm attaching an xml document to this email so you'll know what the above
code is attempting to parse.

Marc

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Schreck, Tom
Sent: Monday, March 04, 2002 11:56 AM
To: [EMAIL PROTECTED]
Subject: RE: [cf-xml] xml - cf question


What's XMLHTTP.4.0 and DOMDocument.4.0?  Is DOMDocument.4.0 a new API for
accessing an XML document's tree?

Tom

-----Original Message-----
From: Dylan Bromby [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 1:44 PM
To: [EMAIL PROTECTED]
Subject: Re: [cf-xml] xml - cf question


We're currently invoking XMLHTTP.4.0 and DOMDocument.4.0 using CFOBJECT in
CF5ENT to send SOAP envelopes to a remote server. Haven't had any trouble
with mem leaks so far...

HTH,

--Dylan

----- Original Message -----
From: "Schreck, Tom" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 04, 2002 11:28 AM
Subject: [cf-xml] xml - cf question


What's the best way to get an xml document available so you can manipulate
it using xml Dom?  I've heard that cfobjects can produce leaks.

Thanks - Tom

-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml





-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

Reply via email to