Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,
i am using fusion charts in my project.it takes data in the form of xml string,so currently for each chart i create dynamic xml string.since there are too many charts,seems i have ended up writing repeated kinda code,
XML
 xmlData.Append("<chart showLegend='1' bgColor='FFFFFF' caption='Project Type:"+ strprojtyp
+ "' subCaption='% of Backlog Hours For Job Codes'"
+ " palette='2' animation='0' formatNumberScale='0' pieSliceDepth='30' startingAngle='125' showBorder='0' showpercentvalues='1'"
+ " showlabels='0' legendNumColumns='2' legendPosition='BOTTOM' minimiseWrappingInLegend='0' enablesmartlabels='0' exportEnabled='1' exportAtClient='0' exportFileName='" + GetFileName(true) + "'"
+ " exportAction='save' exportHandler='" + HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)
                    + HttpRuntime.AppDomainAppVirtualPath
                    + "/App/LPMN/FCExporter.aspx'>");


nothing changes here except caption and export handler and the datatable which i bind the data to it,
XML
 foreach (DataTable dtable in ds.Tables)
   {
xmlData.Append("<set label='" + dtable.TableName + "' value='" + dtable.Rows[0][0].ToString()
 + "' link='j-linkChart-" + strsplt[0] + "~" + strsplt[1] + "'/>");
   }


is there any way i can avoid the repeated xml string creation.

thanks for all your help,
Posted

define a method that generates your string and pass in your variable terms as parameters!
 
Share this answer
 


1.Create a predefined HEADER string value for unchangeable elements of your XML
2.In your foreach loop, you can generate the required DATA results as string
3.Concatenate your DATA string inside the HEADER string
and then,you can easily convert the string as XML

--Sowraaj

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900