2015-08-24 55 views
0

我從Web服務請求獲取了此XML結果。盒子裏面的標籤是我從xml結果中需要的。解析來自Web服務請求的XML結果Java

enter image description here

這是我到目前爲止有:

private Node getMessageNode(QueryResponseQueryResult paramQueryResponseQueryResult, String[] paramArrayOfString) 
    { 

MessageElement[] arrayOfMessageElement = paramQueryResponseQueryResult.get_any(); 
    Document localDocument = null; 
    String res; 
    try 
    { 
     localDocument = arrayOfMessageElement[0].getAsDocument(); //result from the webservice 
    } 
    catch (Exception localException) {} 
    if (localDocument == null) { 
     return null; 
    } 
    Object localObject = localDocument.getDocumentElement(); 
    localObject = Nodes.findChildByTags((Node)localObject, paramArrayOfString); 
    return localDocument; //This returns the XML above 
    } 

如何解析結果返回只包裝盒上的這些標籤,仍然返回爲XML類型?

在此先感謝。

+0

有人向您發送嵌入XML Schema的XML數據嗎?哇,這真的很糟糕。 – Andreas

回答

0

您可以使用XQuery的Xpath執行此任務。

你應該得到的文件,然後你可以使用 getElementByTagName("table")表上的子節點或運行的XPath:

here一個很好的XPath教程。