2010-04-22 4 views
1

나는 큰 xml을 grails에서 flex로 넘겼습니다. flex가 xml을 수신하면 xml을 연관 배열 객체로 변환합니다. 큰 xml 파일이 주어지면 루프를 완료하는 데 너무 오래 걸립니다. flex를 사용하면 변환 속도가 빨라 집니까? 아래는 샘플 코드입니다.xml을 배열로 바꾸는 빠른 방법 (grails to flex)

<xml> 
    <car> 
     <model>Vios</model> 
     <type>Sedan</type> 
     <color>Blue</color> 
    </car> 
    <car> 
     <model>Camry</model> 
     <type>Luxury</type> 
     <color>Black</color> 
    </car> 
</xml> 

*converted to the flex associative array below.* 
[Vios].type = Sedan 
     .color = Blue 
[Camry].type = Luxury 
     .color = Black 

*Below is a code I used in flex to convert the xml to the associative array object* 
var tempXML=xml.children() 
var tempArray:Array= new Array() 
for(var i:int=0;i<tempXML.length();i++) 
{ 
    tempArray[tempXML[i][email protected]]= new Object(); 
    tempArray[tempXML[i][email protected]].color = tempXML[i][email protected](); 
    tempArray[tempXML[i][email protected]].type = tempXML[i][email protected](); 
} 
+0

XML을 어떻게 가져 오나요? HTTPService 사용? – ilikeorangutans

+0

예, httpservice를 통해 xml을 검색합니다. –

답변

0

당신은 array에 HTTPService를 resultFormat을 설정할 수 있습니다. 배열을 곧바로 가져와야합니다 (Flex에서 파싱되었지만 여전히 약간의 시간이 걸릴 수 있습니다)

+0

위에서 만든 연관 객체 배열을 만들려면 resultFormat을 어떻게 설정해야합니까? –

+0

"개체"일 가능성이 있습니다. 전체 목록은 여기에서 확인할 수 있습니다. http://livedocs.adobe.com/flex/3/langref/mx/rpc/http/HTTPService.html#resultFormat –

관련 문제