2013-02-22 56 views
0

新行結腸和顯示我在XML標記像這樣的字符串:分割字符串由從XML

He is what do you need to study: <Enter> 
(i) Study chapter by chapter. 
(ii) Work out the revision question. 

但它顯示這樣

He is what do you need to study:(i) Study chapter by chapter.(ii) Work out the revision question. 

我那麼如何可以顯示像它是如何在XML中。

+0

替換 「<」 與<和 「>」 與> – 2013-02-22 18:58:17

+0

他縮進等在輸出XML – 2013-02-22 18:58:37

+0

使用換行裝置。嘗試使用\ n和\ t格式化它。此外,如果您使用的是xml文件,請使用一些xml庫而不是簡單的文件io操作來讀取它。你上面給出的是簡單的文本文件。 XML中有標籤來定義值。對你的問題更具體一些。 – 2013-02-22 19:00:50

回答

2

假設你正在使用HTML:

Here is what do you need to study: 
    <ul type="upper-roman"> 
     <li>Study chapter by chapter.</li> 
     <li>Work out the revision question.</li> 

    </ul> 

你的意思是這樣嗎?

<div> 
    Here is what do you need to study: 
    <ul type="upper-roman"> 
     <li style="padding-left:20pt" >Study chapter by chapter.</li> 
     <li style="padding-left:20pt" >Work out the revision question.</li> 
    </ul> 
</div> 
+0

我現在能夠得到整個字符串我怎樣才能在冒號後分開它:並在接下來的行顯示2? – Goofy 2013-02-22 18:59:41

+0

是的,我使用html – Goofy 2013-02-22 19:06:36

+0

不,我動態顯示數據,所以如果它包含(i)和(ii)或類似的東西,那麼我需要首先檢查,所以如果它包含然後添加
標記和顯示, – Goofy 2013-02-22 19:14:15

0
<?xml version="1.0"?> 
<a> 
<![CDATA[ 
He is what do you need to study: <Enter> 
(i) Study chapter by chapter. 
(ii) Work out the revision question. 
]]> 
</a>