Skip to main content
Inspiring
September 6, 2007
Question

XML HELP!!!

  • September 6, 2007
  • 1 reply
  • 223 views
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 .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!

This topic has been closed for replies.

1 reply

Inspiring
September 6, 2007
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!