我要讓那些句子,以XML製作與第1句|第2 | 3 |根據特殊規格
I will meet you at 1st.
5th... OK, 5th?
today is 2nd\n
Aug.3rd
像這種4日至XML:
<Text VAlign="top" VPosition="85.00">
I will meet you at 1<Font Script="super">st</Font>.
</Text>
<Text VAlign="top" VPosition="85.00">
5<Font Script="super">th</Font>... OK, 5<Font Script="super">th</Font>
</Text>
<Text VAlign="top" VPosition="85.00">
today is 2<Font Script="super">nd</Font>\n
</Text>
<Text VAlign="top" VPosition="85.00">
Aug.3<Font Script="super">rd</Font>\n
</Text>
我使用minidom命名,但在許多帖子和答案後,我不介意用其他解析器重寫我的代碼。在開始時,我認爲這很容易,只需將st|nd|rd|th
替換爲
<Font Script="super">st|nd|rd|th</Font>
然後用這個新字符串創建TextTextNode()。
但是,通過writexml()方法將符號<, > and "
變成< > and $quot;
。它適用於XML規範,但不適合閱讀。
我該怎麼辦?非常感謝。
感謝您的答覆。但是我的輸出沒有縮進和換行符,我的環境:Python 2.6.6(r266:84292,2013年11月22日,12:11:10) [GCC 4.4.7 20120313(Red Hat 4.4.7-4 )]在linux2上 –