XMLTextWriter changing my variable in a URL (changes instances of & to &)

jbl_ks

Member
Joined
Dec 16, 2010
Messages
24
Programming Experience
Beginner
XMLTextWriter changing my variable in a URL (changes instances of & to &)

Hoping to get an answer without posting a code example for now.

My program creates two files with the same exact information. A text file and an XML file.
There are several variable values and strings outputted to these files,one of which is a URL for a web page.

The text file, created using TextWriter outputs the correct values, including the URL.

The XML file that is created, in each instance where the string variable for the URL is placed, a substitution is made. Where there is supposed to be a literal &, XMLTextWriter is putting a &
I want to output the literal &

http://somedomain.com/xx/v=76&x=484231&y= and so on

http://somedomain.com/xx/v=76&x=484231&y and so on

I put a test in the code one line above the line that outputs the URL string, xmlWriter.WriteString(strTargetURL)

Debug.WriteLine(strTargetURL) and it correctly prints http://somedomain.com/xx/v=76&x=484231&y and so on

The very next line, xmlWriter.WriteString(strTargetURL) outputs the string with & instead of just the & http://somedomain.com/xx/v=76&x=484231&y and so on

It is driving me crazier than I already was.
Thanks
jbl
 
& is a special character in xml and used in content it is encoded & It is decoded to & when reading the content back from xml.
 
I didn't set up any default reader for xml files on my system and when I double click the file it opens in Adobe Dreamweaver. Dreamweaver does no conversion and it displays the &
If I open an xml file in Windows Internet Explorer I do see a conversion from & to just the amperstand.
I guess that I live with the results that I have now.
Thanks
 
Back
Top