2017-08-29 58 views
0

以後的事就是我的輸入特殊漢字即可使用XML標籤命名實體轉換VB.NET

<tag>If milk prices increased from €355 to €420/t</tag> 

我需要像下面

<tag>If milk prices increased from &euro;355 to &euro;420/t</tag> 

轉換我嘗試下面的代碼:

dim tmpstr as String = System.Net.WebUtility.HtmlEncode(outStr) 

但它轉換xml標籤<,我也需要執行內部xml只。如何轉換那件事?

+1

你期望'如果牛奶價格從增加什麼€ 355至€ 420/t'可以使用或不使用DTD來聲明實體'euro'? –

回答

0

創建XML文檔

Dim doc As XmlDocument = New XmlDocument() 
doc.LoadXml("yourstr") 
dim InnerText as string = doc.ChildNodes.Item(0).InnerText 

現在你可以做你想做的的innerText

所有節點上,您可以使用此

For Each node As XmlNode In doc.ChildNodes 
     Dim innertext As String = node.InnerText 
     innertext = innertext.Replace("*", " ") 
     node.InnerText = innertext 
Next 
+0

如果我的xml文檔包含很多標籤意味着 – Malathi

+0

所以我編輯了答案。 – snoopcommands