I'm seeing strange behavior when working with XML files that concerns me a
bit and I was hoping someone could help explain what was going on here. I
have a simple XML file:
<?xml version="1.0" encoding="iso-8859-1"?>
<authors>
<author>
<name idd="VH">Victor Hugo</name>
<nationality>French</nationality>
</author>
<author period="classical">
<name>Sophocles</name>
<nationality>Greek</nationality>
</author>
<author>
<name>Leo Tolstoy</name>
<nationality>Russian</nationality>
</author>
<author>
<name>Alexander Pushkin</name>
<nationality>Russian</nationality>
</author>
<author period="classical">
<name>Plato</name>
<nationality>Greek</nationality>
</author>
</authors>
I'm trying to fetch an element using XPath and then delete that element from
the XML Object. The code below works, but I don't think it should. Here's
the code:
<cffile action=""> file="#GetDirectoryFromPath(GetBaseTemplatePath())#simple.xml"
variable="strXmlDoc">
<cftry>
<cfset objRSS = XmlParse( strXmlDoc )>
<cfcatch type="any">
Error: Malformed XML document
<cfabort>
</cfcatch>
</cftry>
<cfif IsDefined( "objRSS" )>
<cfset temp = XmlSearch( objRSS, "/authors/author
[nationality='Russian']" )>
<cfdump var="#temp#">
<cfset ArrayDeleteAt( temp[1], 1 )>
<cfdump var="#temp#">
<cfdump var="#objRSS#">
</cfif>
My concern is with the ArrayDeleteAt() function. The above works, but it
seems a bit odd. Even stranger is that if I change the line to this:
<cfset ArrayDeleteAt( temp[1][1], 1 )>
it still works. Furthermore, if I change the line to this:
<cfset ArrayDeleteAt( temp[1][1][1][1][1][1][1][1][1][1][1][1], 1 )>
it STILL works. Can anyone explain what is going on here? Thanks!!
Ryan Hagan
ph: 540-731-3588
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

