Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 705
  • Last Modified:

XML issues in flex

I am using Flex Builder 3.0 and i keep getting XML issues when loading XML data using mx:HTTPService.  The XML is formated properly because I have tested it in Internet Explorer.  Is there a method where I can use in ActionScript so that if there is a Invalid formatted record it doesn't stop loading the data but skips over that XML record?

I get the following error code



Error #1096: XML parser failure
/* This is the datagrid for loading the xml data */
	<mx:DataGrid y="106.95" width="90%" editable="false" id="grdanalytics" height="85%" horizontalCenter="5" cachePolicy="off">
		<mx:columns>
			
			<mx:DataGridColumn dataField="posttype" width="5" headerText="">
			      <mx:itemRenderer>
			          <mx:Component>
			                  <mx:Image source="{data.posttype}" height="5" width="5" maintainAspectRatio="true"/>
			          </mx:Component>
			      </mx:itemRenderer>
			     </mx:DataGridColumn>
			
			
			
		<mx:DataGridColumn headerText="Title" dataField="title" width="45" wordWrap="true">
		   <mx:itemRenderer>
		           <mx:Component>
		                   <mx:Text htmlText="{data.title}"/>  
		           </mx:Component>
		   </mx:itemRenderer>
		</mx:DataGridColumn>
			
		<mx:DataGridColumn headerText="Discussion" dataField="discussion" width="17"/>
			<mx:DataGridColumn headerText="Country" dataField="country" width="12"/>
			<mx:DataGridColumn headerText="Date" dataField="rtDate" width="12"/>			
		</mx:columns>
	</mx:DataGrid>
	<mx:Grid y="64.95" width="90%" horizontalCenter="4">
		<mx:GridRow width="100%" height="100%">
			<mx:GridItem width="100%" height="100%">
				<mx:ComboBox width="90%" id="lstcountry" labelField="label" dataProvider="{sercountry.lastResult.countires.ctnry}" change="handleCloseEventCountry(event);"></mx:ComboBox>
			</mx:GridItem>
			<mx:GridItem width="100%" height="100%">
				<mx:ComboBox id="pstType" width="90%" labelField="label" dataProvider="{serpostType.lastResult.posttypes.post}" change="handleCloseEventTone(event);"></mx:ComboBox>
			</mx:GridItem>
			<mx:GridItem width="100%" height="100%">
				<mx:ComboBox width="90%" id="lstdiscussion" dataProvider="{serDiscussion.lastResult.discussions.diss}" labelField="label" change="handleCloseEventDiscussion(event)"></mx:ComboBox>
			</mx:GridItem>
			<mx:GridItem width="100%" height="100%">
				<mx:ComboBox width="90%" labelField="label" id="lstpages" change="handleCloseEventPages(event);" dataProvider="{getPages.lastResult.pages.pgno}"></mx:ComboBox>
			</mx:GridItem>
		</mx:GridRow>
	</mx:Grid>
	<mx:Grid y="10" width="90%" height="46.95" horizontalCenter="4" verticalScrollPolicy="off" horizontalScrollPolicy="off">
		<mx:GridRow width="100%" height="100%">
			<mx:GridItem width="100%" height="100%" horizontalAlign="left">
				<mx:ComboBox width="204" id="lstCompanies" labelField="name" dataProvider='{getCompanies.lastResult.companies.company}' change="HdlCompanies(event);"></mx:ComboBox>
				<mx:Button label="Refresh" id="rfresh" click="refreshData()"/>
			</mx:GridItem>
			<mx:GridItem width="100%" height="100%">
			</mx:GridItem>
			<mx:GridItem width="100%" height="100%">
				<mx:TextInput id="txtSearch"/>
				<mx:Button label="Search" id="btnSearch" click="RTSearch()"/>
			</mx:GridItem>
		</mx:GridRow>
		<mx:GridRow width="100%" height="100%">
			<mx:GridItem width="100%" height="100%">
			</mx:GridItem>
			<mx:GridItem width="100%" height="100%">
			</mx:GridItem>
			<mx:GridItem width="175" height="100%" horizontalAlign="left">
				<mx:RadioButton label="Company" groupName="filterSearch" selected="true" id="rdCompany"/>
				<mx:RadioButton label="All" groupName="filterSearch" id="rdAll"/>
			</mx:GridItem>
		</mx:GridRow>
	</mx:Grid>

Open in new window

0
stargateatlantis
Asked:
stargateatlantis
  • 2
  • 2
1 Solution
 
lexxwernCommented:
>>  Is there a method where I can use in ActionScript so that if there is a Invalid formatted record
>> it doesn't stop loading the data but skips over that XML record?

Probably yeah. You need to setup a fault handler for the HTTPService or use Try Catch for error handling.
0
 
stargateatlantisAuthor Commented:

But lets say there is a error in the record.  Is there a way to skip that record and process the next instead of the whole thing crashing?
0
 
lexxwernCommented:
You need to verify and validate the XML before passing it on as the dataProvider.
0
 
stargateatlantisAuthor Commented:
Can you give me a example of how to do this.  That would be great
0
 
rascalpantsCommented:
to answer your question...

">>  Is there a method where I can use in ActionScript so that if there is a Invalid formatted record
>> it doesn't stop loading the data but skips over that XML record?"


no...  your XML has to be valid... even using a try catch in actionscript is not the answer, because the data has to be well formed BEFORE it gets into the programming.


I would recommend restricting who can update the XML, AFTER you make sure it is completely validated and accessible to AS 3 code.


rp / ZA

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now