CopyPastor

Detecting plagiarism made easy.

Score: 1; Reported for: Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2018-08-02
by Rahul Tripathi

Original Post

Original - Posted on 2015-01-02
by Amit Merin



            
Present in both answers; Present only in the new answer; Present only in the old answer;

As suggested in this [blog][1] you can try like this:
string _byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()); if (xml.StartsWith(_byteOrderMarkUtf8)) { xml = xml.Remove(0, _byteOrderMarkUtf8.Length); }

[1]: https://www.ipreferjim.com/2014/09/data-at-the-root-level-is-invalid-line-1-position-1/
The hidden character is probably BOM. The explanation to the problem and the solution can be found [here][1], credits to James Schubert, based on an answer by James Brankin found [here][2].
Though the previous answer does remove the hidden character, it also removes the whole first line. The more precise version would be:
string _byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()); if (xml.StartsWith(_byteOrderMarkUtf8)) { xml = xml.Remove(0, _byteOrderMarkUtf8.Length); }
I encountered this problem when fetching an XSLT file from Azure blob and loading it into an XslCompiledTransform object. On my machine the file looked just fine, but after uploading it as a blob and fetching it back, the BOM character was added.

[1]: http://www.ipreferjim.com/2014/09/data-at-the-root-level-is-invalid-line-1-position-1/ [2]: https://stackoverflow.com/questions/17947238/why-data-at-the-root-level-is-invalid-line-1-position-1-for-xml-document/24513288#24513288

        
Present in both answers; Present only in the new answer; Present only in the old answer;