also, if you have ie5 on your server, then a version will already be
installed. there was a newer version with better spec conformance in beta a
while back, but i don't know what the status is on it now.
this is oversimplified, but as a starting point:
<cfscript>
xmlParser = CreateObject("COM", "Microsoft.XMLDOM");
xmlParser.load("http://somewhere.com/structure.xml");
</cfscript>
josh
-----Original Message-----
From: David Gassner [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 31, 2000 4:47 PM
To: [EMAIL PROTECTED]
Subject: RE: XML to Structure
I've used the MS XMLDOM COM object to read an XML file with 1-to-many
relationships into an multi-dimensional array of structures. I haven't used
on a very large document, but I suppose that given sufficient memory and
time it would work fine. You can get the COM object from:
http://msdn.microsoft.com/downloads/tools/xmlparser/xmlparser.asp
These are the object methods and properties I used:
XMLDOMDocument. The top node containing the entire XML DOM tree.
* Async. When set to True (the default setting), returns control to the
caller before the download is finished. In ColdFusion, this can cause a
partial document load, so set it to False.
* Load(url). Loads the XML tree from a web document.
* getElementsByTagName(nodename). Returns a list of document-level Nodes
where the NodeName matches the argument.
hasChildNodes(). Returns True if the Node has Child Nodes.
XMLDOMNodeList. A collection of nodes in the document tree, supporting
iteration with <cfloop>.
XMLDOMNode. A single node in the document tree.
* hasChildNodes(). Returns True if the Node has children, False if it doesn
t.
* childNodes(). Returns all of the Nodes child nodes as an XMLDOMNodeList.
* selectNodes(nodename). Returns an XMLDOMNodeList of the current Nodes
children where the NodeName matches the argument.
* Attributes. Returns a collection of Attributes, each of which consists of
a key-value pair.
* Text. The value between the Nodes begin and end tags.
Here's some sample code to instantiate the object and read in a top-level
node list:
<cfobject type="COM" name="xmlDoc" class="Microsoft.XMLDOM" action="CREATE">
<cfset xmlDoc.async = false>
<cfset xmlDoc.load(url of file)>
<!--- Create an XMLDOMNodeList --->
<cfset nodes = xmlDoc.getElementsByTagName(nodeName)>
<cfset nodeArray = Arraynew(1)>
<!--- Loop through the nodes --->
<cfloop collection="#nodes#" item="thisNode">
<!--- For each node, append a structure to the array --->
<cfset ArrayAppend(nodeList, structnew()>
<cfset nodeIndex = ArrayLen(nodeList)>
<!--- Get the node's text and its other attributes into the structure --->
<cfset nodeList[nodeIndex]["Text"] = thisNode.Text>
<cfset attributeList = thisNode.Attributes>
<cfloop collection="#attributeList#" index="thisAttribute">
<cfset nodeList[nodeIndex][thisAttribute.nodeName] = thisAttribute.Text>
</cfloop>
</cfloop>
The full documentation for the COM object is at:
http://msdn.microsoft.com/library/psdk/xmlsdk/xmld2rl1.htm
--David Gassner
> Has anybody had any success in creating an array of structures
> from an XML
> document?
>
> I have a 30,000 item catalog that is in XML that I have to import into my
> DB Server but I also have to do some data checking via CF.
>
> Any help would be great
----------------------------------------------------------------------------
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=sts&body=sts/cf_talk or send
a message to [EMAIL PROTECTED] with 'unsubscribe' in the
body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.