Hi guys,
My issue is i have some non standard XML and i need to tidy it before it can be parsed with an XElement.Parse(text) function the problem is that the source is as follows (just a sample, the entire file contains many items)
notice the "-" now initially i tried to replace these with "" using string.replace("-", "") but the resulting string is the same.Code:−<item> <id>3050</id> <name>Change of Heart</name> <plural_name>Changes of Heart</plural_name> − <image_url> {some encoded url that i removed} </image_url> <color>Black</color> <attack>10</attack> <defense>20</defense> <favor_points>0</favor_points> <cost>100</cost> <num_owned>1</num_owned> <item_limit>0</item_limit> <enhancements/> − <details> %3Cspan%20class%3D%27itemTitle%27%3E%20Change%20of%20Heart%3C%2Fspan%3E%3Cbr%3E </details> <category>OBJECT</category> <sub_category>extras</sub_category> </item>
I then looked into these dashes and found that if i url encode the string that these dashes consist of 3 chars ie (in % hexadecimal):-
%E2%88%92
i converted these to decimal and created a string of these chars as follows:-
Dim glut As String = Chr(227) & Chr(136) & Chr(146)
i then replaced any occurrence of this string in the text and again it is still there. Any ideas how i can remove these artifacts from my xml so i can parse it correctly?
The original XML is beyond my control
Here is the relevant code i have used
Code:Option Strict On Option Explicit On Imports System Imports System.Web Imports System.Text Public Class Form1 Private Sub btn_populate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_populate.Click Dim content As String = TextBox1.Text Dim glut As String = Chr(227) & Chr(136) & Chr(146) content = content.Replace(glut, "") TextBox1.Text = HttpUtility.UrlDecode(content) End Sub Private Sub btn_encode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_encode.Click Dim content As String = TextBox1.Text TextBox1.Text = HttpUtility.UrlEncode(content) End Sub End Class![]()




Reply With Quote