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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:28:22+00:00 2026-05-29T07:28:22+00:00

In short, is it possible to use a DTD to define an element as

  • 0

In short, is it possible to use a DTD to define an element as containing CDATA?

I’m calling a third party API that produces some invalid characters inside an element. Specifically, the data contains some HTML entities like ’. When I attempt to parse this XML using SimpleXML, I of course get a parser error “Entity ‘rsquo’ not defined”. Here’s a simplistic example structure of what I’m dealing with:

<items>
    <item>
        <name>Jim Smith</name>
        <description>Jim&rsquo;s description breaks my parser</description>
    </item>
</items>

Since I don’t have control to fix the API response… I’ve resorted to this dirty trick to inject a CDATA section inside the problem element just before I try to parse it:

$xml = str_replace("<description>", "<description><![CDATA[", $xml);
$xml = str_replace("</description>", "]]></description>", $xml);

This fixes the issue for me, but the overhead is probably too big, don’t you think? The XML can be anywhere between 30K to 100K of data.

I’d rather use a DTD but for the life of me I can’t find any specs that allow for defining CDATA (in the same way I can define PCDATA). Below is what I’d like to do, but of course, it’s invalid because of the ‘#CDATA’ definition I’m trying to do:

<!DOCTYPE ITEMS [
    <!ELEMENT ITEMS (ITEM)>
    <!ELEMENT ITEM (NAME, DESCRIPTION)>
    <!ELEMENT NAME (#PCDATA)>
    <!ELEMENT DESCRIPTION (#CDATA)>
]>

Thanks for any insights!

  • 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-29T07:28:23+00:00Added an answer on May 29, 2026 at 7:28 am

    It is possible in SGML DTDs (e.g. the HTML 4.01 script element), but not in XML DTDs (hence the change for XHTML 1.0).

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

Sidebar

Related Questions

Short version : Is it possible or not to use impersonation in ASP.NET to
I'd like a short smallest possible javascript routine that when a mousedown occurs on
Possible Duplicate: Calling Python from Objective-C I'm a long-time Python programmer and short-time Cocoa
I'm looking into some possible options for unit testing C++ classes. So, short and
I have a really short question: Is it possible to communicate/use USB devices on
Possible Duplicate: Are PHP short tags acceptable to use? Which is better to use,
The short question: how can I (or is it possible to) make use of
Possible Duplicates: Are PHP short tags acceptable to use? Reference - What does this
Possible Duplicate: Are PHP short tags acceptable to use? We are currently using a
A short question for the PROs. Is it possible to use Zend_Auth_Adapter_DbTable with ZendX_Db_Adapter?

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.