PDA

View Full Version : Error #1090: XML parser failure


cmgmyr
04-05-2008, 09:06 PM
Hello,
I'm making a new Flex 3 App and I keep on getting "Error #1090: XML parser failure: element is malformed." when I try and submit my form.

Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" verticalAlign="middle">

<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;

[Bindable]
private var diamondList:XMLList;

public function handleXML(event:ResultEvent):void{
diamondList = event.result.diamond as XMLList;
}

public function handleFault(event:FaultEvent):void{
Alert.show(event.fault.faultString, "Error");
}
]]>
</mx:Script>

<mx:HTTPService result="handleXML(event);" fault="handleFault(event);" resultFormat="e4x" id="xmlRPC" method="GET" url="http://localhost/zzz_stuff/flex/diamondSearch/zzz_flex.php" useProxy="false">
<mx:request xmlns="">
<lot_number>{lot_number.text}</lot_number>
<price_from>price.values[0]</price_from>
<price_to>price.values[1]</price_to>
</mx:request>
</mx:HTTPService>

<mx:Label x="34" y="32" text="Lot Number" width="77" height="18" textAlign="right" fontWeight="bold"/>
<mx:Label x="34" y="58" text="Price" width="77" height="18" textAlign="right" fontWeight="bold"/>
<mx:TextInput x="130" y="32" id="lot_number" width="160" height="22"/>
<mx:HSlider x="130" y="62" labels="['0','10000']" id="price" maximum="10000" thumbCount="2" showTrackHighlight="true" values="[4900, 5000]"/>
<mx:Button x="130" y="106" label="Get Diamonds" click="xmlRPC.send();" width="160" height="22"/>
<mx:DataGrid dataProvider="{diamondList}" x="34" y="141" width="1068" height="459" id="diamondSearchList" editable="false" enabled="true">
<mx:columns>
<mx:DataGridColumn headerText="Lot Number" dataField="lot_number" />
<mx:DataGridColumn headerText="Carat" dataField="carat" />
<mx:DataGridColumn headerText="Shape" dataField="shape" />
<mx:DataGridColumn headerText="Color" dataField="color" />
<mx:DataGridColumn headerText="Clarity" dataField="clarity" />
<mx:DataGridColumn headerText="Price" dataField="price_a" />
</mx:columns>
</mx:DataGrid>

</mx:Application>

and here is the XML
- <diamonds>
- <diamond>
<lot_number>10318</lot_number>
<carat>2.25</carat>
<shape>OV</shape>
<color>H</color>
<clarity>VS2</clarity>
<price_a>4950</price_a>
</diamond>
- <diamond>
<lot_number>10396B</lot_number>
<carat>2.06</carat>
<shape>TR</shape>
<color>I</color>
<clarity>SI1</clarity>
<price_a>4900</price_a>
</diamond>
- <diamond>
<lot_number>10543</lot_number>
<carat>1.15</carat>
<shape>PS</shape>
<color>D</color>
<clarity>VS2</clarity>
<price_a>4900</price_a>
</diamond>
- <diamond>
<lot_number>10586</lot_number>
<carat>1.76</carat>
<shape>OV</shape>
<color>E</color>
<clarity>SI1</clarity>
<price_a>4920</price_a>
</diamond>
- <diamond>
<lot_number>10600</lot_number>
<carat>2.08</carat>
<shape>OV</shape>
<color>I-J</color>
<clarity>SI2</clarity>
<price_a>4950</price_a>
</diamond>
- <diamond>
<lot_number>B-6052A</lot_number>
<carat>2.08</carat>
<shape>AS</shape>
<color>H</color>
<clarity>VS2</clarity>
<price_a>4950</price_a>
</diamond>
</diamonds>

Everything looks ok to me. Can anyone help me out?

Thanks,
-Chris

cmgmyr
04-06-2008, 01:44 PM
UPDATE:
I took out these 2 lines and it worked
<price_from>price.values[0]</price_from>
<price_to>price.values[1]</price_to>

How do I get the 2 values from the slider into the request?

Thanks,
-Chris

kahuja
04-06-2008, 08:01 PM
How do I get the 2 values from the slider into the request?


You have me confused now, in XML you do not use arrays, but if there are any arrays and when you serialize them to a XML it takes the shape of something like below:

<elements>
<element/>
<element/>
<element/>
<element/>
</elements>


Did this help?

cmgmyr
04-06-2008, 09:25 PM
I think the actual XML is ok, I think it was just sending bad information to the php file. I ended up using: <price_from>{price.values[0]}</price_from>
<price_to>{price.values[1]}</price_to> which is working, but it's giving me a warning "Data binding will not be able to detect changes when using square bracket operator. For Array, please use ArrayCollection.getItemAt() instead." on those 2 lines. Any ideas on this?

Sorry again for the noob questions haha.

Thanks!

kahuja
04-07-2008, 02:45 AM
You can not use bindings to the elements in Array, which breaks the MVC architecture. If you are not so much using the MVC, then you are fine, else you will have to look for an alternative approach

cmgmyr
04-07-2008, 08:08 PM
so how do I get those 2 values from the slider into the request?