Reputation: 3
while getting attribute values from XML file by using XSLT function got error like below "Invalid character in the given encoding. Line 71, position 109.".
he line has '—' in that position. How to avoid this error? or any other method is there to read?
Thanks.
Upvotes: 0
Views: 391
Reputation: 338336
How to avoid this error?
By only modifying XML with XML-aware tools. This rules out text editors, sed, awk, string replace operations, producing XML by concatenating strings ... anything that writes strings to files, really.
XML-aware tools are tools that have an internal XML parser, e.g. the XML API of your programming language of choice or command line tools like xsltproc.
any other method is there to read?
No. A broken file is a broken file.
As to fixing the file: Byte encoding must match the XML declaration. If there is a byte sequence in the file that does is not present the declared encoding, then you'll see the "invalid character" error message. You can then use a text editor to replace the offending byte(s) with something that is valid in the declared encoding.
Upvotes: 1