Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / September 2007



Tip: Looking for answers? Try searching our database.

XML HELP!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AdobeCF7User - 06 Sep 2007 07:24 GMT
I've accessed simpler documents using code like this:

         <cfscript>
            selectedElements = XmlSearch(XmlData, "/TopLevel/NextLevel");
            for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1);
         </cfscript>

         <cfloop from="1" to="#arraylen(selectedElements)#" index="i">
            <cfoutput>#selectedElements[i].elementNameinXML.XmlText#<cfoutput>
         </cfloop>

But I can't seem to access the data in this more complex document.  I hope
someone can show me what I'm doing wrong here so I can access all the data in
the doc.  

Thanks in advance!

DOC:

  <?xml version="1.0" encoding="unicode" ?>
- <taskWizardRun taskName="Move Mailbox" dcName="SERVER08" buildNumber="7638"
runningAs="johnbdoe@doe.com">
  <timespan startTime="2007-09-05 18:30:00.341" milliseconds="4177375" />
- <moveMailbox mixedMode="false" maxBadItems="0">
- <destination>
  <database>/dc=com/dc=doe/cn=Configuration/cn=Services/cn=Microsoft
Exchange/cn=Doe/cn=Administrative Groups/cn=First Administrative
Group/cn=Servers/cn=SERVER08/cn=InformationStore/cn=SG1/cn=SGA</database>
  </destination>
  </moveMailbox>
  <taskSummary errorCount="0" completedCount="2" warningCount="0"
errorCode="0x00000000" />
- <items>
- <item adsPath="janesmith" class="user">
  <progress code="-6" milliseconds="4177359" />
- <summary isWarning="false" errorCode="0x00000000">
  The operation has completed successfully.
- <details>
- <source>
  <database>/dc=com/dc=doe/cn=Configuration/cn=Services/cn=Microsoft
Exchange/cn=Doe/cn=Administrative Groups/cn=First Administrative
Group/cn=Servers/cn=SERVER01/cn=InformationStore/cn=SG2/cn=SGB</database>
  </source>
  </details>
  </summary>
  </item>
- <item adsPath="johnsmith" class="user">
  <progress code="-6" milliseconds="1649406" />
- <summary isWarning="false" errorCode="0x00000000">
  The operation has completed successfully.
- <details>
- <source>
  <database>/dc=com/dc=doe/cn=Configuration/cn=Services/cn=Microsoft
Exchange/cn=Doe/cn=Administrative Groups/cn=First Administrative
Group/cn=Servers/cn=SERVER04/cn=InformationStore/cn=SG3/cn=SGC</database>
  </source>
  </details>
  </summary>
  </item>
  </items>
  </taskWizardRun>

If I do:

         <cfscript>
            selectedElements = XmlSearch(XmlData, "/taskWizardRun");
            for (i = 1; i LTE ArrayLen(selectedElements); i = i + 1);
         </cfscript>

and then dump selectedElements i see the whole XML structure

If I try "/taskWizardRun/timespan" and dump it I get the timespan structure.  
But if I try to access the elements in taskWizardRun (taskName, dcName,
buildNumber, runningAs) or in timespan(startTime,milliseconds) I get errors.  
I'm definitely doing something wrong!
AdobeCF7User - 06 Sep 2007 07:37 GMT
In the dump it shows the elements in a structure so I added this code:

<cfscript>
CD=StructNew();
CD=selectedElements[1];
CDE=StructNew();
CDE=CD.XmlAttributes;
</cfscript>

<p><cfoutput>#CDE.starttime# #CDE.milliseconds#</cfoutput>

And I was able to access the starttime and milliseconds values.  

There must be a better way!
GArlington - 06 Sep 2007 09:37 GMT
> In the dump it shows the elements in a structure so I added this code:
>
[quoted text clipped - 10 lines]
>
>  There must be a better way!

If you are unsure about the object structure - dump complete object
<cfdump var="selectedElements" />
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.