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 639423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:50:27+00:00 2026-05-13T20:50:27+00:00

In my XML, it’s possible for an apostrophe to appear in a node’s value:

  • 0

In my XML, it’s possible for an apostrophe to appear in a node’s value:

<Root>
    <Sections>
        <SectionA>
            <Heading>Title</Heading>
            <Description>This is section 'A'</Description>
        </SectionA>
    </Sections>
</Root>

If I have controls bound to this XML:

<asp:FormView ID="myFormView" runat="server" DataSourceID="myXmlDataSource">
    <ItemTemplate>
        <div>
            HTML Element:
            <input type="text" value='<%# XPath("text()") %>' />
        </div>
        <div>    
            Server Control:
            <asp:TextBox id="myTextBox" runat="server" value='<%# XPath("text()") %>' />
        </div>
    </ItemTemplate>
</asp:FormView>           
<asp:XmlDataSource ID="myXmlDataSource" runat="server" XPath="Root/Sections/SectionA" />

I’ve noticed that the text is correctly displayed in the asp:TextBox but not in the INPUT element. I’m assuming that it’s because server controls correctly escape the apostrophe. To work around this, I tried changing the Description node in the XML to the following:

<Description>This is section &#39;A&#39;</Description>

Again, this displayed correctly in the asp:TextBox, but not in the INPUT element.

My next attempt was to wrap the node’s value in a CDATA:

<Description><![CDATA[This is section &#39;A&#39;]]></Description>

Finally it was displaying correctly in the INPUT element, but now the asp:TextBox displayed the two “& # 3 9 ;”. I’ve even tried “& a p o s ;” but the result is the same.

What is the best approach for the use of apostrophes in XML where the value can be displayed in either a server control or HTML element?

  • 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-05-13T20:50:28+00:00Added an answer on May 13, 2026 at 8:50 pm

    Here you have single quotes surrounding the value argument for the html element:

     <input type="text" value='<%# XPath("text()") %>' />
    

    This renders:

    value='This is section 'A'' 
    

    Instead use double quotes:

     <input type="text" value="<%# XPath("text()") %>" />
    

    Which renders:

    <input type="text" value="This is section 'A'" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

xml: <root> <element>value (something)</element> </root> I need to unmarshall this xml to two different
XML NODE <!-- url path=/jsp/Admin_BetaSignup.jsp roles=ZohoCampaignAdmin authentication=optional description=Page used to add the Beta users>
XML: <root> <event title=Title1 /> <event title=Title2 /> </root> C# public static string **retunxml**(){
XML <Data> <Language Name=ru-Ru> <Item Id=1>value</Item> <Item Id=2>value2</Item> </Language> </Data> Is it possible to
XML File Sample <GateDocument> <GateDocumentFeatures> ... </GateDocumentFeatures> <TextWithNodes> <Node id=0/> MESSAGE SET <Node id=19/>
xml: <skills> <skill>PHP</skill> <skill>CSS</skill> <skill>HTML</skill> <skill>XML</skill> </skills> XSL: <ul> <xsl:for-each select=skills/skill> <li><xsl:value-of select=[what should
My XML node have 6 attributes but the thing is from these attributes I
My XML file looks like this: <Messages> <Contact Name=Robin Number=8775454554> <Message Date=24 Jan 2012
Xml response is like , but in one tag , the text is this:
XML file: <books> <scifi key=...> <author>Don Larson</author> <title>The Edge</title> <year>...</year> </scifi> <scifi key=...> <author>Don

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.