Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8572461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:01:01+00:00 2026-06-11T19:01:01+00:00

After an XSLT transformation I keep getting leading question marks that (seem to) have

  • 0

After an XSLT transformation I keep getting leading question marks that (seem to) have to do with character encoding, but I can’t get rid of them. I have tried all different encodings, but it didn’t help. I’m stuck with an in-memory xml source, as I serialize objects.

This is my code (as short as possible to reproduce the problem)

var xd = new XmlDocument();
xd.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?><Test><AAA>AAA</AAA></Test>");

var xslt = new System.Xml.Xsl.XslCompiledTransform();
xslt.Load(Server.MapPath("/Transformations/Test.xslt"));

using (var ms = new MemoryStream())
{
    xslt.Transform(xd, null, ms);
    ms.Position = 1;

    using (var sr = new StreamReader(ms, System.Text.Encoding.UTF8, true))
    {
        string s = sr.ReadToEnd();
    }
}

And this is the XSLT:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="text"  indent="no"/>
    <xsl:template match="Test">
        BBB<xsl:value-of select="AAA" />CCC
    </xsl:template>
</xsl:stylesheet>

Produces:

��\r\n\t\tBBBAAACCC\r\n\t

It’s probably very simple, but I can’t figure it out…

Regards,

Heras

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:01:02+00:00Added an answer on June 11, 2026 at 7:01 pm

    Set the ms.Position to 0 instead of 1

    C# arrays are zero indexed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XSLT transformation I have two analyze-strings that I need to use to
I am just getting into xslt transformation and after going through a tutorial I
I am working under java application which uses XSLT transformation. I have a lot
I have a following xslt: <span><xsl:text disable-output-escaping=yes><![CDATA[&nbsp;Some text]]></xsl:text></span> After transformation I get: <span>&amp;nbsp;Some text</span>
I have modified the title of the question after finding the answer :) :P
i have to build an XSLT stylesheet that transforms an xml like this: <message>
I have an xml content and i am applying xslt 1.0 for transformation on
Question Using XSLT 1.0, given a string with arbitrary characters how can I get
after about 3 hours of tinkers with xslt, I have the following output <?xml
After deploying WCF server (svc) on my Server, I have got this message when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.