2013-02-21 43 views
0

我有一個靜態字符串,在我的android應用程序,它是XML格式。我想將該文件存儲在某個變量中。一種方法是將其存儲在res/string.xml文件夾中。但是,當我這樣做,我得到這個錯誤在哪裏存儲靜態字符串數據的XML格式?

The processing instruction target matching "[xX][mM][lL]" is not allowed. 

另一種方法是初始化與XML字符串一個字符串變量。但是,我想這不是一個好的方法。

我的XML字符串下面給出:

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<soap:Body> 
<DumpStudentData xmlns="http://www.milpahost.com/"> 
<objUserRequest> 
<CourseId xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Milpa.Server.WcfService.BusinessObjects">6</CourseId> 
<MachineId xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Milpa.Server.WcfService.BusinessObjects">8qK6HM8LuAXq8bLROSsVjZ5u8Adn3IvvvLXDDe85Rq3Zi1hIQZZY8o6eyJPCYIgqdDRgRgqbK6RAdtJ3GXU73Q==</MachineId> 
<ProviderId xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Milpa.Server.WcfService.BusinessObjects">6</ProviderId> 
<StudentId xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Milpa.Server.WcfService.BusinessObjects">13</StudentId> 
<UserLiveInternalId xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Milpa.Server.WcfService.BusinessObjects">t=EwCgAa49BAAUdcc7Ta21slZda8sE9GInYkjRfuqAAFJh913naiYqRXhwp4INykAokezK77PZMZbccki2rUVcGM6iApglemodzHEo7Tg3aOAOfWbK2upbG3bPEvHi0DmlfDrMSUhTG7/z6QEIgkCMIlObhixIKLAxnBYQOf/kCNeV4nWWJRf4/hWiiEyogswdnkyRPmxepJXB5yS0R39xA2YAAAiYaPHDKmep4/AAkG1tI4kB7hTQjTlcGCSdQurmtw2yuGNZiQzP+QkoYW43rd0Z5EFAMJfHEwjQOIlvSC8qBiU6S7nGkl9gAhdKMwRi6t2PE/0ROkJrmLUZ5B8/v3pcYhNEA1/plZ7vx/+olxRzvqwH8LG3ygO7zpx7CxChtodm1uLDA1wQEpE3LyqxfyQgWauj3vYXdzPjyF7xsIHeytrWUisUhrB7jw7sMVQv+X14Fw8GXYrfxli5E/lWIx1UADS1ak53BdVk/aov1aBHLOMo0QhzvIfT8dxThBOEpQSjx76PElodDmN43r/A0jer5Jepsl3/RnXs98v4MAE=&amp;p=</UserLiveInternalId> 
<UserLiveLoginId xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Milpa.Server.WcfService.BusinessObjects">[email protected]</UserLiveLoginId> 
</objUserRequest> 
<listOfDumps><ContentDump><ContentId>1</ContentId><XmlContent>&lt;DoubtsStore xmlns="http://www.milpahost.com/DoubtsStore.xsd" /&gt;</XmlContent></ContentDump><ContentDump><ContentId>2</ContentId><XmlContent>&lt;AssessmentProficiency xmlns="http://www.milpahost.com/AssessmentProficiency.xsd"&gt; 

我怎麼能存儲這個字符串常量?

+0

把這個xml文件存儲爲一個資產文件怎麼樣? – Yury 2013-02-21 11:23:39

+0

@Yury是的,這是一種方式,但我不會喜歡,因爲閱讀文件會使應用程序變得緩慢 – Jaguar 2013-02-21 11:25:31

+0

你有關於此的任何數字嗎?你是否嘗試從資產文件中讀取數據並測量時間? – Yury 2013-02-21 11:31:58

回答

0

你有沒有試過在CDATA中放入字符串?

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <string name="string_name"> 
<![CDATA[ 

    <?xml version="1.0" encoding="utf-8"?> 
    <soap:Envelope> 
     .... 
    </soap:Envelope> 

]]>   
    </string> 

</resources>