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

  • Home
  • SEARCH
  • 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> <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
I have an xml like this <?xml version=1.0 encoding=UTF-8 ?> <product> <productname> ----->Dynamic node
This XML file contained archived news stories for all of last year. I was
The XML I'm trying to validate is as follows: <root> <element attribute=foo> <bar/> </element>
XML, Why are null char disallowed even in CDATA sections? It seems to terminate
With XML XSLT, it is possible to build a nice template in HTML, convert
my xml is : <Window.Resources> <Style TargetType=ListViewItem> <Setter Property=HorizontalContentAlignment Value=Stretch /> </Style> </Window.Resources> <Grid
Which XML structure allows me faster adding,deleting,updating of a node? My assumption is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.