2010-05-14 53 views
0

我查看了所有內容並決定創建我自己的庫來訪問EVE API。使用POST解析互聯網上的Java文檔

請求被髮送到服務器地址,如/account/Characters.xml.aspx。 Characters.xml.aspx要求在POST中提交兩個項目,然後返回一個XML文件。到目前爲止,我有這個,但它不工作,可能是監守我使用GET而不是POST:

//Get the API data 
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
    DocumentBuilder builder = factory.newDocumentBuilder(); 
    String url = "http://api.eveonline.com/account/Characters.xml.aspx?userID="+ 
      userID+"?apiKey="+key; 
    Document doc = builder.parse(url); 

我怎麼會去能夠parst由在POST提交變量生成一個XML文件?

+0

大概要高度: http://wiki.eve-id.net/APIv2_Account_Characters_XML和 http://www.eveonline.com/api/doc/authentication.asp – Travis 2010-05-14 06:12:01

+0

此外,完整的地址,這個API請求將是http://api.eveonline.com/account/Characters.xml.aspx – Travis 2010-05-14 06:14:44

回答

0

我不知道DocumentBuilder.parse(String uri)是否會獲取遠程URI。無論如何,你是對的,如果是的話,它很可能會得到。

您應該使用HTTP客戶端庫來執行POST並獲取響應。一個選項是: http://hc.apache.org/httpclient-3.x/ 他們有一些例子,所以你不應該用它來做你的文章,得到結果,然後使用DocumentBuilder建立一個DOM並得到你想要的東西它。