" "
' '
< <
> >
& &
How can i prevent the error raising?You can't (well actually you can but the file will not be continued to parse)
(and modifying the xml-source is not an option)The only option that I know of is to make a request to one of the working groups and ask if for your specific use case they want to change the XML standards.
How can i prevent the error raising?You can't (well actually you can but the file will not be continued to parse)Quote(and modifying the xml-source is not an option)The only option that I know of is to make a request to one of the working groups and ask if for your specific use case they want to change the XML standards.
But perhaps there is a more practical solution to go about it, like f.e. not accepting any files not adhering to the XML standard or write your own custom XML parser.
Or using a Sax-based parser instead of a Dom-based one.Although SAX based parsing is a bit more tolerant - in the sense that it can probably recover - to misformed XML that makes it not not-misformed XML.
Afaik & needs to be escaped as &, so that code is probably not proper XMLCode: [Select]" "
' '
< <
> >
& &
Are these the only 5 xml-instances with an ampersand?W3schools, XML syntax (https://www.w3schools.com/XML/xml_syntax.asp) paragraph Entity References
Pass your input string (after reading it from the stream) through the following function which replaces isolated '&' by '&':
function FixXML(XMLStr: String): String; ...
These ampersands need to remain, so your solution does not work in my case.Then do not call it XML, because it isn't.
the rest of the string has some nodevalue's with CDATA in it. These ampersands need to remain, so your solution does not work in my case.Then take it as an idea how to extend it yourself.
or write your own custom XML parser.
Code: [Select]procedure MutilateValidXML(var list:Tstringlist);
That is called a one-liner. Do it for the other escapes too, that makes a five liner.. :P
begin
list.text := stringreplace(list.text, '&','&',[rfReplaceAll,rfIgnorecase]);
end;
But when does OP finally understand he is not handling XML but something that resembles it?Thanks for knowing what i do or do not understand.
Note that TS seem to refuse to budge the viewpoint in any way.And what gave you that idea?
If you are creating these original XML strings, ..........