"<?xml version=\"1.0\"?>"
+ "<methodResponse>"
+ "<fault>"
+ "<value>"
+ "<struct>"
+ "<member>"
+ "<name>faultCode</name>"
+ "<value>"
+ "<int>"
+ "-1"
+ "</int>"
+ "</value>"
+ "</member>"
+ "<member>"
+ "<name>faultString</name>"
+ "<value>"
+ "<string>"
+ "The element type value must be terminated by the matching end-tag </value>"
+ "</string>" + "</value>" + "</member>" + "</struct>"
+ "</value>" + "</fault>" + "</methodResponse>";
在這裏,當我嘗試添加文本元素類型的值必須由匹配的結束標籤被終止,則拋出空指針異常。我該如何處理這個問題。我希望以下部分拋出錯誤。問題在於「結束標籤」。我該如何處理這個問題。印刷XML格式錯誤
+ "<string>"
+ "The element type value must be terminated by the matching end-tag </value>"
+ "</string>" +
我該如何轉義<>標記。我是否需要用<替換它還是有其他方法嗎? – BKK
正如代碼示例所示,將「<」替換爲「<」和「>」替換爲「>」。您可能想閱讀[XML轉義](http://en.wikipedia.org/wiki/XML#Escaping) – MadProgrammer
我會使用'String.replace'之類的東西,但正如Jon所說,我會也可以使用XML API – MadProgrammer