[英]How to Handle XML string using VB.net where attribute have html value
我試圖解析一個XML文件,其中屬性值在vb.net中具有html數據,並拋出異常'<'(十六進制值0x3c),這是無效的屬性字符。 。
我的樣本XML是這樣的:
<root>
<control id="ctrl" type="paragraph" label="Declare"
text="<b>Your idea has been posted successfully.Visit again to see updates on your ideas.</b>" visible="true" >
</control>
</root>
我曾嘗試用&lt和&lg替換字符<和>。 但我無法解決此解析錯誤問題。
您無法解析此XML,因為它無效。 看一下XML規范 。
<
和>
(以及其他一些字符)不用作標記定界符,則必須轉義( <
和>
),否則它們必須是CDATA節的一部分。
因此,修復您的XML,然后可以對其進行解析。
您需要對文本的值進行html編碼 ,如下所示:
<root>
<control
id="ctrl"
type="paragraph"
label="Declare"
text="<b>Your idea has been posted successfully.Visit again to see updates on your ideas.</b>"
visible="true">
</control>
</root>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.