A semi colon character was expected. Error processing resource '...
<key>SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CNXT_MODEM_PCI_VEN_8086&DEV
How can I avoid this error being printed out when viewing my XML file in a browser? It seems to complain because of the '&' character, how do I escape it? thank开发者_如何转开发s.
Try escaping it with &
.
The & character should be escaped as &
, as per the XML standard. See this SO question for more info.
You need to use the character entity &
You will also probably experience issues with the open angle bracket, which needs to be encoded as <
How did you create such XML? I bet you created it using string manipulation, as no self-respecting XML API would have produced such invalid XML.
This is why to create XML using XML APIs instead of string APIs.
var keyElement = new XElement(
"key", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\CNXT_MODEM_PCI_VEN_8086&DEV");
Problem solved.
To escape an ampersand:
&
I had same issue and fixed it by using the following:
translate(replace(replace(TaskType),'&',' '),' > & < / \ " - ''',' ')
it removed all & and hyphen characters. I believe XML does not like those characters.
精彩评论