我无法从我收到的数据中提取 url。
数据是
<ASX VERSION="3.0"><TITLE>iROCK109 - Classic Rock And More!</TITLE><MOREINFO HREF="http://www.irock109.com/" /><COPYRIGHT>� iROCK109 - 2009</COPYRIGHT><ABSTRACT>Classic Rock n More!</ABSTRACT><ENTRY><TITLE>[128k] www.irock109.com</TITLE><REF HREF="http://cp6.digistream.info:20366/" /><AUTHOR>iROCK 109 - Classic Rock And More!</AUTHOR><ABSTRACT>DJ Hosted Classic Rock 60s through today, and requests 24/7</ABSTRACT>
我正在使用的代码是从 REF 读取数据和提取 HREF 是
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
executeHttpGet();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//Method for http request
public void executeHttpGet() throws Exception {
BufferedReader in = null;
try {
System.out.println("ndkjsdak");
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
HttpProtocolParams.setUseExpectContinue(client.getParams(), false);
request.setURI(new URI("http://www.irock109.com/streams/irock109-128mp3.asx"));
//HttpResponse response = client.execute(request);
HttpResponse response = null;
boolean RetryConnection = true;
int retrycount = 0;
//retry request 5 times
while(RetryConnection == true && retrycount < 5)
{
try
{
response = client.execute(request);
RetryConnection = false;
}
catch(IOException e)
{
System.out.println("caught");
retrycount += 1;
}
}
in = new BufferedReader
(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null)
{
sb.append(line +NL);
}
in.close();
String page=sb.toString();
System.out.println("xml data "+page);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput( new StringReader (page) );
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT)
{
if(eventType == XmlPullParser.START_DOCUMENT)
{
System.out.println("Start document");
}
else if(eventType == XmlPullParser.START_TAG)
{
System.out.println("Start tag "+xpp.getName());
}
else if(eventType == XmlPullParser.END_TAG)
{
System.out.println("End tag "+xpp.getName());
}
else if(eventType == XmlPullParser.TEXT)
{
System.out.println("Text "+xpp.getText());
}
eventType = xpp.next();
}
System.out.println("End document");
}
finally
{
if (in != null)
{
try
{
in.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
我怎样才能得到href
from ref
?