我一直在試圖從xml中提取cdata,但沒有成功。這是我的代碼。用actionscript提取xml cdata 3
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="myData.send();" backgroundColor="white" >
<mx:HTTPService id="myData" resultFormat="e4x" url="./assets/rawXML.xml" result="handleResult1(event)"/>
<mx:Script><![CDATA[
import mx.collections.XMLListCollection;
import mx.rpc.events.*;
[Bindable]
private var firstName:String;
[Bindable]
private var myXML:XMLList;
private function handleResult1(event:ResultEvent):void{
myXML = event.result.ROW;
for each(var siteXML:XML in myXML){
firstName = siteXML..SC_DF_FIELD_3.text();
}
}
]]>
</mx:Script>
<mx:TextArea text = "{firstName}" height="200" width="800"/>
</mx:Application>
這是我的XML;
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myFirstTemplate.xsl"?>
<ViewAll>
<RECORDSET_METADATA>
<STARTREC>1</STARTREC>
<KEYFIELDS>True</KEYFIELDS>
<ENDREC>6</ENDREC>
<TOTALREC>6</TOTALREC>
<PAGE_NO>1</PAGE_NO>
<SORT_TYPE>DT_UPDATED</SORT_TYPE>
<SORT_ORDER>desc</SORT_ORDER>
<FORM_ID>414898</FORM_ID>
<REPORT_ID></REPORT_ID>
<SAVED_ID></SAVED_ID>
<NEXTSORTORDER>
<![CDATA[&sortorder=desc]]>
</NEXTSORTORDER>
<SC_DF_XSL_HELP_URL>
<![CDATA[http://libraries.ge.com/LibrariesWiki/2767051101/Data%20Forms%20-%20Customizing%20Records%20View]]>
</SC_DF_XSL_HELP_URL>
<FILTER_DATA>
<![CDATA[var AdvSrchFltrXML_String = { AdvSrchFltrData : { filter : [ {selElementType : '',selElementParentDF : '',selComb : '',exclCheck : '',selElement : '',query : '',query_psrch : '',includeNull : '',lockFilter : '',lockFilterFlg : '',dateFrom : '',dateTo : '',betweenDaysFrom : '',betweenDaysTo : '',betweenDaysFromOption : '',betweenDaysToOption : '',exactDaysOption : '',exactDays : '',moreThanOption : '',moreThan : '',NumAgingQuery : '',betweenNumFrom : '',betweenNumTo : '',GreaterOrLessOrEqualToNum : '',dateFromFormat : '',dateToFormat : ''} ] },size : 1, HiddenXMLFilterCount :''}]]>
</FILTER_DATA>
<FILTER_FIELDS>
<![CDATA[ var arrFields = new Array(new Array("form_doc_id","Entry #","req","","","","",""),new Array("LOGGED_BY","Logged By","psrch","","","","","1"),new Array("DT_LOGGED","Date Logged","dt","","","","",""),new Array("LAST_UPDATED_BY","Last Updated By","psrch","","","","","1"),new Array("DT_UPDATED","Date Updated","dt","","","","",""),new Array("el_values_field3","Name","t","","","5707420","alpha","0"))]]>
</FILTER_FIELDS>
<GENERATE_HIDDEN_VAR>
<![CDATA[]]>
</GENERATE_HIDDEN_VAR>
<HIDDEN_XML_FILTER_COUNT>
<![CDATA[]]>
</HIDDEN_XML_FILTER_COUNT>
<HIDDEN_FILTER_REMOVE_NUMBER>
<![CDATA[]]>
</HIDDEN_FILTER_REMOVE_NUMBER>
<DF_LINK_FIELDS_VAR>
<![CDATA[]]>
</DF_LINK_FIELDS_VAR>
<SA_UPLOAD_FLAG>
<![CDATA[-1]]>
</SA_UPLOAD_FLAG>
<FLG_EXPORT_PDF_WORD>0</FLG_EXPORT_PDF_WORD>
<FLG_DISABLE_BULK_UPDATE_APPEND>0</FLG_DISABLE_BULK_UPDATE_APPEND>
<FLG_EXPORT_KML>1</FLG_EXPORT_KML>
<FLG_EXPORT_TO_MAP>0</FLG_EXPORT_TO_MAP>
<FLGFULLTXTSEARCH>0</FLGFULLTXTSEARCH>
<PUBLISHED_FLAG>0</PUBLISHED_FLAG>
<STR_CREATE_ORDER>402</STR_CREATE_ORDER>
<FUNC_CREATE_ORDER>asc</FUNC_CREATE_ORDER>
<FORM_NAME>FSR Map Points</FORM_NAME>
<PROD_ID>267672</PROD_ID>
<ARCHIVE_FLAG>0</ARCHIVE_FLAG>
<FACILITATOR_FLAG>1</FACILITATOR_FLAG>
<ADVANCED_SEARCH_FLAG>1</ADVANCED_SEARCH_FLAG>
<EXPORT_ALL_FLAG>1</EXPORT_ALL_FLAG>
<EXPORT_PAGE_FLAG>0</EXPORT_PAGE_FLAG>
<DELETE_RECORD_FLAG>1</DELETE_RECORD_FLAG>
<FIELDCHOOSER_EDIT_FLAG>1</FIELDCHOOSER_EDIT_FLAG>
<FIELDCHOOSER_COPY_FLAG>1</FIELDCHOOSER_COPY_FLAG>
<RSS_FEED>1</RSS_FEED>
<FIELD_CHOOSER_ENABLE_FLAG>1</FIELD_CHOOSER_ENABLE_FLAG>
<ARCHIVE_ALL_ENABLE_FLAG>1</ARCHIVE_ALL_ENABLE_FLAG>
<TRUNCATE_TEXT_FLAG>0</TRUNCATE_TEXT_FLAG>
<CALLED_FOR></CALLED_FOR>
<CALLING_ENTITY_TYPE></CALLING_ENTITY_TYPE>
<EXCELUPLOADFLAG>true</EXCELUPLOADFLAG>
<VIEWAUDITTRAIL>1</VIEWAUDITTRAIL>
<STATICSERVER>//static.supportcentral.com</STATICSERVER>
<VIEWERS_DETAIL>
<V_SSO_ID>222222222</V_SSO_ID>
<V_PERSON_ID>1273000</V_PERSON_ID>
<V_FIRST_NAME>Geoffrey</V_FIRST_NAME>
<V_LAST_NAME>Goodman</V_LAST_NAME>
<V_BUSINESS_SEGMENT>Power & Water</V_BUSINESS_SEGMENT>
<V_FOCUS_GROUP>GE Power & Water</V_FOCUS_GROUP>
<V_SUB_BUSINESS>PW-WTR Water</V_SUB_BUSINESS>
<V_LANGUAGE>english</V_LANGUAGE>
<V_FUNCTION>Services</V_FUNCTION>
</VIEWERS_DETAIL>
</RECORDSET_METADATA>
<DFLINK_ELEMENT_DETAILS>
<CalledForSF display_name="CalledForSF" search_field="No">&nbsp</CalledForSF>
<SOURCE_ELEMENT_ID display_name="SOURCE_ELEMENT_ID" search_field="No">&nbsp</SOURCE_ELEMENT_ID>
<TARGET_ELEMENT_ID display_name="TARGET_ELEMENT_ID" search_field="No">&nbsp</TARGET_ELEMENT_ID>
</DFLINK_ELEMENT_DETAILS>
<DF_FIELDS>
<SC_SYS_DF_FORM_DOC_ID display_name="Entry #" search_field="Yes">Entry #</SC_SYS_DF_FORM_DOC_ID>
<SC_SYS_DF_DT_LOGGED display_name="Date Logged" search_field="Yes">Logged Date</SC_SYS_DF_DT_LOGGED>
<SC_SYS_DF_DT_UPDATED display_name="Date Updated" search_field="Yes">Last Updated Date</SC_SYS_DF_DT_UPDATED>
<SC_SYS_DF_LOGGED_BY display_name="Logged By" search_field="Yes">Logged by</SC_SYS_DF_LOGGED_BY>
<SC_SYS_DF_LAST_UPDATED_BY display_name="Last Updated By" search_field="Yes">Last Updated By</SC_SYS_DF_LAST_UPDATED_BY>
<SC_SYS_DF_AUDIT_TRAIL_HEADER display_name="Audit Trail" search_field="Yes">Audit Trail</SC_SYS_DF_AUDIT_TRAIL_HEADER>
<SC_DF_FIELD_3 display_name="Name" element_type="t" search_field="Yes" Inactive_user="0">Name</SC_DF_FIELD_3>
</DF_FIELDS>
<HEADER>
<SC_SYS_DF_FORM_DOC_ID display_name="Entry #" search_field="Yes">Entry #</SC_SYS_DF_FORM_DOC_ID>
<SC_SYS_DF_DT_LOGGED display_name="Date Logged" search_field="Yes">Logged Date</SC_SYS_DF_DT_LOGGED>
<SC_SYS_DF_DT_UPDATED display_name="Date Updated" search_field="Yes">Last Updated Date</SC_SYS_DF_DT_UPDATED>
<SC_SYS_DF_LOGGED_BY display_name="Logged By" search_field="Yes">Logged by</SC_SYS_DF_LOGGED_BY>
<SC_SYS_DF_LAST_UPDATED_BY display_name="Last Updated By" search_field="Yes">Last Updated By</SC_SYS_DF_LAST_UPDATED_BY>
<SC_SYS_DF_AUDIT_TRAIL display_name="Audit Trail" search_field="Yes">Audit Trail</SC_SYS_DF_AUDIT_TRAIL>
<SC_DF_FIELD_1 display_name="Menu L1" element_type="t" search_field="No">Menu L1</SC_DF_FIELD_1>
<SC_DF_FIELD_2 display_name="Menu L2" element_type="t" search_field="No">Menu L2</SC_DF_FIELD_2>
<SC_DF_FIELD_3 display_name="Name" element_type="t" search_field="Yes">Name</SC_DF_FIELD_3>
<SC_DF_FIELD_4 display_name="Information" element_type="t" search_field="No">Information</SC_DF_FIELD_4>
<SC_DF_FIELD_5 display_name="City, State" element_type="t" search_field="No">City, State</SC_DF_FIELD_5>
<SC_DF_FIELD_6 display_name="Latitude" element_type="t" search_field="No">Latitude</SC_DF_FIELD_6>
<SC_DF_FIELD_7 display_name="Longitude" element_type="t" search_field="No">Longitude</SC_DF_FIELD_7>
</HEADER>
<ROW edit_access="1">
<SC_SYS_DF_FORM_DOC_ID_ACTION display_name="Entry # For Actions">
<![CDATA[6193418162]]>
</SC_SYS_DF_FORM_DOC_ID_ACTION>
<SC_SYS_DF_FORM_DOC_ID display_name="Entry #">
<![CDATA[6193418162]]>
<ENTRY_VIEW_URL display_name="View Entry URL">
<![CDATA[http://supportcentral.com/dataforms/sup_dataform_display.asp?dataform_id=414898&dataform_doc_id=6193418162]]>
</ENTRY_VIEW_URL>
</SC_SYS_DF_FORM_DOC_ID>
<SC_SYS_DF_DT_LOGGED display_name="Date Logged">
<![CDATA[4/4/2013 9:27:46 AM]]>
</SC_SYS_DF_DT_LOGGED>
<SC_SYS_DF_DT_UPDATED display_name="Date Updated">
<![CDATA[4/4/2013 9:27:46 AM]]>
</SC_SYS_DF_DT_UPDATED>
<SC_SYS_DF_LOGGED_BY display_name="Logged By">
<![CDATA[ ]]>
<PERSON>
<SC_DF_PERSON_LINK display_name="Profile Url">
<![CDATA[../common/sup_persondtls.asp?p_id=2348753]]>
</SC_DF_PERSON_LINK>
<SC_DF_SSO display_name="">
<![CDATA[218010000]]>
</SC_DF_SSO>
<SC_DF_EMAIL display_name="Email">
<![CDATA[[email protected]]]>
</SC_DF_EMAIL>
<SC_DF_FIRST_NAME display_name="First Name">
<![CDATA[Joseph]]>
</SC_DF_FIRST_NAME>
<SC_DF_LAST_NAME display_name="Last Name">
<![CDATA[ulo]]>
</SC_DF_LAST_NAME>
</PERSON>
<PERSON_STRING>
<PERSON_STRING_VAR display_name="person person person">
<![CDATA[var person_String = {person : [ {PERSON_ID : '../common/sup_persondtls.asp?p_id=2348753',FIRST_NAME : 'Joseph',LAST_NAME:'ulo'}], size : 1 }]]>
</PERSON_STRING_VAR>
</PERSON_STRING>
</SC_SYS_DF_LOGGED_BY>
<SC_SYS_DF_LAST_UPDATED_BY display_name="Last Updated By">
<![CDATA[ ]]>
<PERSON>
<SC_DF_PERSON_LINK display_name="Profile Url">
<![CDATA[../common/sup_persondtls.asp?p_id=2348753]]>
</SC_DF_PERSON_LINK>
<SC_DF_SSO display_name="">
<![CDATA[218010000]]>
</SC_DF_SSO>
<SC_DF_EMAIL display_name="Email">
<![CDATA[[email protected]]]>
</SC_DF_EMAIL>
<SC_DF_FIRST_NAME display_name="First Name">
<![CDATA[Joseph]]>
</SC_DF_FIRST_NAME>
<SC_DF_LAST_NAME display_name="Last Name">
<![CDATA[ulo]]>
</SC_DF_LAST_NAME>
</PERSON>
<PERSON_STRING>
<PERSON_STRING_VAR display_name="person person person">
<![CDATA[var person_String = {person : [ {PERSON_ID : '../common/sup_persondtls.asp?p_id=2348753',FIRST_NAME : 'Joseph',LAST_NAME:'ulo'}], size : 1 }]]>
</PERSON_STRING_VAR>
</PERSON_STRING>
</SC_SYS_DF_LAST_UPDATED_BY>
<SC_SYS_DF_AUDIT_TRAIL display_name="Audit Trail">
<![CDATA[<a href="../caseforms/complete_audit_trail.asp?calling_entity_id=414898&form_doc_id=6193418162&pageNo=0&auditType=0&callingEntity=4" target="_none">Audit Trail</a>]]>
</SC_SYS_DF_AUDIT_TRAIL>
<SC_DF_FIELD_1 display_name="Menu L1" element_type="t" data_type="alpha">
<![CDATA[FSR]]>
</SC_DF_FIELD_1>
<SC_DF_FIELD_2 display_name="Menu L2" element_type="t" data_type="alpha">
<![CDATA[Mobile Man]]>
</SC_DF_FIELD_2>
<SC_DF_FIELD_3 display_name="Name" element_type="t" data_type="alpha">
<![CDATA[ulo, Joseph]]>
</SC_DF_FIELD_3>
<SC_DF_FIELD_4 display_name="Information" element_type="t" data_type="alpha">
<![CDATA[Northeast Territory]]>
</SC_DF_FIELD_4>
<SC_DF_FIELD_5 display_name="City, State" element_type="t" data_type="alpha">
<![CDATA[Virginia Beach, VA]]>
</SC_DF_FIELD_5>
<SC_DF_FIELD_6 display_name="Latitude" element_type="t" data_type="alpha">
<![CDATA[-75.977976563656]]>
</SC_DF_FIELD_6>
<SC_DF_FIELD_7 display_name="Longitude" element_type="t" data_type="alpha">
<![CDATA[36.852930519206]]>
</SC_DF_FIELD_7>
</ROW>
<ROW edit_access="1">
<SC_SYS_DF_FORM_DOC_ID_ACTION display_name="Entry # For Actions">
<![CDATA[6193418164]]>
</SC_SYS_DF_FORM_DOC_ID_ACTION>
<SC_SYS_DF_FORM_DOC_ID display_name="Entry #">
<![CDATA[6193418164]]>
<ENTRY_VIEW_URL display_name="View Entry URL">
<![CDATA[http://supportcentral.com/dataforms/sup_dataform_display.asp?dataform_id=414898&dataform_doc_id=6193418164]]>
</ENTRY_VIEW_URL>
</SC_SYS_DF_FORM_DOC_ID>
<SC_SYS_DF_DT_LOGGED display_name="Date Logged">
<![CDATA[4/4/2013 9:27:46 AM]]>
</SC_SYS_DF_DT_LOGGED>
<SC_SYS_DF_DT_UPDATED display_name="Date Updated">
<![CDATA[4/4/2013 9:27:46 AM]]>
</SC_SYS_DF_DT_UPDATED>
<SC_SYS_DF_LOGGED_BY display_name="Logged By">
<![CDATA[ ]]>
<PERSON>
<SC_DF_PERSON_LINK display_name="Profile Url">
<![CDATA[../common/sup_persondtls.asp?p_id=3282603]]>
</SC_DF_PERSON_LINK>
<SC_DF_SSO display_name="">
<![CDATA[2180200000]]>
</SC_DF_SSO>
<SC_DF_EMAIL display_name="Email">
<![CDATA[[email protected]]]>
</SC_DF_EMAIL>
<SC_DF_FIRST_NAME display_name="First Name">
<![CDATA[Kevin]]>
</SC_DF_FIRST_NAME>
<SC_DF_LAST_NAME display_name="Last Name">
<![CDATA[Woodsman]]>
</SC_DF_LAST_NAME>
</PERSON>
<PERSON_STRING>
<PERSON_STRING_VAR display_name="person person person">
<![CDATA[var person_String = {person : [ {PERSON_ID : '../common/sup_persondtls.asp?p_id=3282603',FIRST_NAME : 'Kevin',LAST_NAME:'Woodsman'}], size : 1 }]]>
</PERSON_STRING_VAR>
</PERSON_STRING>
</SC_SYS_DF_LOGGED_BY>
<SC_SYS_DF_LAST_UPDATED_BY display_name="Last Updated By">
<![CDATA[ ]]>
<PERSON>
<SC_DF_PERSON_LINK display_name="Profile Url">
<![CDATA[../common/sup_persondtls.asp?p_id=3282603]]>
</SC_DF_PERSON_LINK>
<SC_DF_SSO display_name="">
<![CDATA[218020000]]>
</SC_DF_SSO>
<SC_DF_EMAIL display_name="Email">
<![CDATA[[email protected]]]>
</SC_DF_EMAIL>
<SC_DF_FIRST_NAME display_name="First Name">
<![CDATA[Kevin]]>
</SC_DF_FIRST_NAME>
<SC_DF_LAST_NAME display_name="Last Name">
<![CDATA[Woodsman]]>
</SC_DF_LAST_NAME>
</PERSON>
<PERSON_STRING>
<PERSON_STRING_VAR display_name="person person person">
<![CDATA[var person_String = {person : [ {PERSON_ID : '../common/sup_persondtls.asp?p_id=3282603',FIRST_NAME : 'Kevin',LAST_NAME:'Woodsman'}], size : 1 }]]>
</PERSON_STRING_VAR>
</PERSON_STRING>
</SC_SYS_DF_LAST_UPDATED_BY>
<SC_SYS_DF_AUDIT_TRAIL display_name="Audit Trail">
<![CDATA[<a href="../caseforms/complete_audit_trail.asp?calling_entity_id=414898&form_doc_id=6193418164&pageNo=0&auditType=0&callingEntity=4" target="_none">Audit Trail</a>]]>
</SC_SYS_DF_AUDIT_TRAIL>
<SC_DF_FIELD_1 display_name="Menu L1" element_type="t" data_type="alpha">
<![CDATA[FSR]]>
</SC_DF_FIELD_1>
<SC_DF_FIELD_2 display_name="Menu L2" element_type="t" data_type="alpha">
<![CDATA[Mobile Man]]>
</SC_DF_FIELD_2>
<SC_DF_FIELD_3 display_name="Name" element_type="t" data_type="alpha">
<![CDATA[Woodsman, Kevin]]>
</SC_DF_FIELD_3>
<SC_DF_FIELD_4 display_name="Information" element_type="t" data_type="alpha">
<![CDATA[Northeast Territory]]>
</SC_DF_FIELD_4>
<SC_DF_FIELD_5 display_name="City, State" element_type="t" data_type="alpha">
<![CDATA[Manchester, NH]]>
</SC_DF_FIELD_5>
<SC_DF_FIELD_6 display_name="Latitude" element_type="t" data_type="alpha">
<![CDATA[-71.454786492200]]>
</SC_DF_FIELD_6>
<SC_DF_FIELD_7 display_name="Longitude" element_type="t" data_type="alpha">
<![CDATA[42.995647573539]]>
</SC_DF_FIELD_7>
</ROW>
</ViewAll>
有關如何讓SC_DF_FIELD_3字段增加的任何建議?無論我嘗試什麼,我只會得到姓氏(伍茲曼,凱文)出現。我很確定它覆蓋每個循環中的fistname變量,但我不知道如何改變它。任何幫助將大大appraciated!
我糾正了函數handleResult1,你有一些行重複。那麼,我不忍心,你可以得到伍茲曼的姓氏,凱文,但你不能得到以前的值?所以,你想要這個:** ulo,Joseph **,** Woodsman,Kevin **? –
+!擁有可運行的樣本。但是,對於你想要展示的東西存在一些困惑。你可以考慮編輯你的問題,或者簡化你的XML,以便更清楚地傳達這個問題。 – JeffryHouser