Solved

Add elements in XML file not declared in the DTD

Posted on 2008-10-09
1
365 Views
Last Modified: 2008-10-15
I have created a DTD with the basic structure of my XML File. But my XML file can contain elements which are not declared in the DTD. How can i acheive this using DTD? Is there any tag in DTD with the help of which this can be acheived?


Suppose my DTD is 
 
<!ELEMENT subject (books, teachers) >
<!ELEMENT books (#PCDATA) >
<!ELEMENT teachers (#PCDATA) >
 
and my XML File is
 
<subject>
   <books>
      <book1 />
      <book2 />
   </books>
   <teachers />
</subject>
 
How can I acheieve this kind of functionality such that my DTD validates my XML file and gives no parsing error.

Open in new window

0
Comment
Question by:jdsiam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 22684618
You can't.
You could use XML Schema.
There you can tell that the content of an element can be anything and that the validation should be "lax" for that part.
With DTD you can't achieve that.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Path of Workbook 3 87
XML Removal- Powershell 4 34
Powershell script to zip up xml files in a directory 13 35
I dont know why my code is no longer working help please 9 71
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question