Perfect.

I knew if I just asked the question I would save my self a lot of stuffing 
around.

Brian Knott
ext 31221

From: [email protected] [mailto:[email protected]] On Behalf Of 
Kevin Pepperman
Sent: Wednesday, 22 July 2009 8:47 AM
To: [email protected]
Subject: [cfaussie] Re: XML Import Issue

Just regular old structKeyExists should do it for you.

if( 
StructKeyExists(xmlfile.body.GetListItemsResponse.GetListItemsResult.listitems.data.row[a].XmlAttributes,
 "ws_Buildlevel")
 )
{
doSomething();
 }


On Tue, Jul 21, 2009 at 6:32 PM, KNOTT, Brian 
<[email protected]<mailto:[email protected]>> wrote:
Hi guys.

Got an XML import issue.  I am trying to import an XML file but I'm having 
issues with some nodes not being defined in the XML.  For example the node 
'duration' may not be define for every record in the XML file.  So I need to 
check to see if the node exists before I reference it, if it does not exist 
then I want to set it as null.  I have tried isdefined and few other but can't 
seem to get the correct terminology.  Code sample below

<cffile action="read" file="d:\Data\wwwroot\misd\XML\modelbuildparms.xml" 
variable="xmlfile">

<cfscript>
        xmlfile = trim(xmlfile);
        xmlfile = xmlparse(xmlfile);

        xmlsize = 
xmlfile.body.GetListItemsResponse.GetListItemsResult.listitems.data.XmlAttributes.ItemCount;

        xmlqry = QueryNew("Title, ModelPath, ModelEmailString, CubePublishPath, 
PPESPublishPath, ModelUserSecurity, ModelBuildExtraCommandsPre, 
ModelBuildExtraCommandsPost, BuildLevel, BusinessName, Duration, Keywords, 
NotifyStatus, MajorGrouping, MinorGrouping, ModelLabel, Frequency, Status, 
PrimaryMDC, ItemType, Path, UpdateTimeStamp, CreatedBy, ModifiedBy, Created, 
Modified, ID");
        QueryAddRow(xmlqry,100);

        for (a=1; a LTE 1; a=a+1) {
                QuerySetCell(xmlqry,"title", 
xmlfile.body.GetListItemsResponse.GetListItemsResult.listitems.data.row[a].XmlAttributes.ows_Buildlevel,a);
                QuerySetCell(xmlqry,"ModelPath", 
xmlfile.body.GetListItemsResponse.GetListItemsResult.listitems.data.row[a].XmlAttributes.ows_ModelPath,a);
        )
</cfscript>

In this example I need to check to see if the 
'xmlfile.body.GetListItemsResponse.GetListItemsResult.listitems.data.row[a].XmlAttributes.ows_Buildlevel'
 node exists before I reference it.

Thanks

Brian Knott
Software Engineer (COGNOS Developer) | MIS Front End | Banking & Life MIS
ext 31221 ph 07 3333 1221



  ________________________________
This e-mail is sent by Suncorp-Metway Limited ABN 66 010 831 722 or one of its 
related entities "Suncorp".
Suncorp may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on 13 11 
55 or at suncorp.com.au<http://suncorp.com.au>.
The content of this e-mail is the view of the sender or stated author and does 
not necessarily reflect the view of Suncorp. The content, including 
attachments, is a confidential communication between Suncorp and the intended 
recipient. If you are not the intended recipient, any use, interference with, 
disclosure or copying of this e-mail, including attachments, is unauthorised 
and expressly prohibited. If you have received this e-mail in error please 
contact the sender immediately and delete the e-mail and any attachments from 
your system.
If this e-mail constitutes a commercial message of a type that you no longer 
wish to receive please reply to this e-mail by typing Unsubscribe in the 
subject line.





--
-- if you've written a homegrown[*CFML] controller layer that rivals the 
sophistication and ease of use of the three major players (MG/MII/FB) - then 
share it or shut up. You code in a silo - that's great. Just stay in there and 
don't try to tell everyone how good it smells.
--Dave Ross


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to