2012-06-12 2 views
1

다음 XML을 구문 분석 할 수있는 방법을 누구에게도 알려줄 수 있습니까? 나는 HttpGet 메서드의 응답으로 다음 xml을 얻는다. 이 xml을 문자열 형식으로 저장할 수 있습니다.Android : XML 문자열에서 속성 값을 가져 오는 방법

<?xml version="1.0" encoding="UTF-8"?> 

<opml version="1"> 

    <head> 

    <status>200</status> 

     </head> 

    <body> 

<outline type="text" text="General" guide_id="f1" is_default="true"/> 

<outline type="text" text="Rock Stations" guide_id="f2"/> 

<outline type="text" text="Rock Stations" guide_id="f3"/> 

<outline type="text" text="Rock" guide_id="f4"/> 

<outline type="text" text="Awdhesh" guide_id="f5"/> 

    </body> 

</opml> 

나는 outline의 속성을 구문 분석되고 싶어요. 또한 listview에 text의 값을 표시하려고합니다. 샘플 코드를 제공해주십시오.

미리 감사드립니다 ... !!!

+0

XML 파서를 사용하고 있습니까? – dirkgently

+0

예,하지만 안드로이드에서 새로 생겨서 속성을 파싱 할 생각이 없지만 상태 값을 파싱 할 수 있습니다. –

+0

[이 튜토리얼 참조] (http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/) – Praveenkumar

답변

0

당신이 SAXParcer를 사용하는 경우, 색소폰 parcer 구현의 예를 참조하십시오

http://mobile.tutsplus.com/tutorials/android/android-sdk-build-a-simple-sax-parser/

이 방법 유의하시기 바랍니다 여기

public void startElement(String uri, String localName, String qName, 
      Attributes attributes) throws SAXException 

당신이 속성과 그 값을 확인할 수 있습니다

if(localName.equals("outline")) 
    String txtValue= attributes.getValue("text"); 
+0

xml 파일이 String 형식입니다. 그럼 내가 어떻게 할 수 있니? –

관련 문제