ah, okay..
well when i process xml, i use this custom tag to convert the xml to a
struct. This custom tag was just available...I assume that a programmer
before me found it. I'm attaching the code for the custom tag, and how i
use it below: because I dont know exactly how your xml is structured, i did
the best with changing the example code... however, you can just do a cfdump
on mystruct after populating, to better see where that "NO" lives.
hope this helps.. (and remember...the custom tag code is attached - just
rename it with a .cfm exention .. i renamed it with a .txt just incase your
firewall prevents it)
<CFOBJECT NAME="objXMLHTTP" CLASS="Microsoft.XMLHTTP" ACTION="create"
TYPE="COM">
<cfscript>
objXMLHTTP.open("POST",theurl,false);
objXMLHTTP.send();
</cfscript>
<cfset xmlresponce = #objXMLHTTP.responseText#>
<cf_xmlchange input #xmlresponce# output="mystruct">
<!--- trying to change code for your purposes --->
<cfif #isdefined("mystruct.events.events[i]")#>
<cfoutput>
<cfset aVal =
mystruct.events.events[i].attributes.attrributeNAMEHERE.value")#>
#aVal#
</cfoutput>
<br>
</cfif>
_________________
John Youngman
[EMAIL PROTECTED]
----- Original Message -----
From: "Tepfer, Seth" <[EMAIL PROTECTED]>
To: <discussion@acfug.org>
Sent: Tuesday, July 15, 2008 9:25 AM
Subject: RE: [ACFUG Discuss] Assistance parsing XML file?
Whoops - yes. Earlier in the processing comes this...
<cffile action="read" file="C:\temp\xmlTest.txt" variable="myxml">
<cfset mydoc = XmlParse(myxml)>
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Youngman
can i assume you are placing your xml into a struct before parsing?
I am having a little trouble parsing this XML file, and could use some
help.
Thanks for any assistance.
When I say:
<cfset aVal =
mydoc.events.event[i].custom_attribute[k].attribute_value>
#aVal# outputs as:
No
But if I use an if to check for "No", I never find it, because in
reality,
<xmp>#aVal#</xmp> outputs as:
<?xml version="1.0" encoding="UTF-8"?>
<r25:attribute_value
xmlns:r25="http://www.collegenet.com/r25">No</r25:attribute_value>
I've resorted to using string functions to parse out all that extra XML
to
get at my actual value. That feels klunky and like the hard way. What
is the
easy way to get to "No" ?
Seth Tepfer 770-784-8487 [EMAIL PROTECTED]
Director of Administrative Computing, Oxford College
Proud Pappa (again): Zyle Caspian, born Thursday, April 17, 2:38 pm. 8
lbs,
19.5 inches. Baby Pix at: http://www.flickr.com/photos/[EMAIL PROTECTED]/
This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.
If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=gin.edituserform
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------
<cfparam name="Attributes.Init" default="1">
<cfif Attributes.Init><!--- if it is the root node --->
<cfparam name="Attributes.Input">
<cfparam name="Attributes.Output" default="Struct">
<cfparam name="Attributes.Type" default="Variable">
<cfobject action="CREATE" class="Microsoft.XMLDom" type="COM" name="XMLDoc">
<cfscript>
XMLDoc.async = 0;
XMLDoc.loadXML(Attributes.Input);
oParseError = XMLDoc.ParseError;
</cfscript>
<!--- if DOM error throw an exception --->
<cfif oParseError.ErrorCode>
<cfthrow type="XMLchange.ParseError" message="DOM Error"
detail="#oParseError.Reason# | Line:#oParseError.Line#">
</cfif>
<cfscript>
Attributes.Node = XMLDoc;
Attributes.Struct = StructNew();
</cfscript><!--- create outputstructure --->
</cfif>
<cfloop collection="#Attributes.Node.childNodes#" item="ThisNode">
<cfswitch expression="#ThisNode.NodeType#">
<cfcase value="1">
<cfset CurrentNode = StructNew()> <!--- initialize node structure --->
<!--- Write Attributes to Structure --->
<cfset CurrentNode["Attributes"] = StructNew()>
<cfloop collection="#ThisNode.Attributes#" item="ThisAttribute">
<cfset CurrentNode.Attributes[ThisAttribute.Name] = ThisAttribute.Value>
</cfloop>
<cfif StructIsEmpty(CurrentNode["Attributes"])>
<cfset StructDelete(CurrentNode,"Attributes")>
</cfif>
<!--- Write current node to Structure --->
<cfscript>
if(isArray(Attributes.Struct)) // Currently part of a collection
Attributes.Struct[ArrayLen(Attributes.Struct)+1] = CurrentNode;
else if(structKeyExists(Attributes.Struct,ThisNode.NodeName)){ //
Duplicate keys found
if (isArray(Attributes.Struct[ThisNode.NodeName])) // Collection
already exists
Attributes.Struct[ThisNode.NodeName][ArrayLen(Attributes.Struct[ThisNode.NodeName])+1]
= CurrentNode;
else{ // Create new collection
TempCollection = ArrayNew(1);
TempCollection[1] = Attributes.Struct[ThisNode.NodeName];
TempCollection[2] = CurrentNode;
Attributes.Struct[ThisNode.NodeName] = TempCollection;
}
}else // Single element
Attributes.Struct[ThisNode.NodeName] = CurrentNode;
</cfscript>
<!--- Recurse if children nodes exist --->
<cfif ThisNode.hasChildNodes()>
<cf_xmlchange init="0" struct="#CurrentNode#" node="#ThisNode#">
<cfelse>
<cfset CurrentNode.Value = "">
</cfif>
</cfcase>
<cfcase value="3,4">
<cfset Attributes.Struct.Value = ThisNode.NodeValue>
</cfcase>
<cfcase value="8">
<cfset Attributes.Struct.Comment = ThisNode.NodeValue>
</cfcase>
</cfswitch>
</cfloop>
<cfif Attributes.Init>
<!--- Return the new structure to the calling template --->
<cfset "Caller.#Attributes.Output#"= Attributes.Struct>
</cfif>
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------