Reputation: 5873
How do I include DTD in a XML document. Please provide me a sample. Thanks
Upvotes: 2
Views: 6958
Reputation: 2516
If you are talking about programmatically adding it in code on an XmlDocument
in C# then you might want to look at the XmlDocument.CreateDocumentType Method.
If not, you might want to expand on what it is you are after exactly.
Upvotes: 2
Reputation: 13350
I prefer to use the XML classes in the System.Xml.Linq
namespace myself because they're much easier to work with. It's very easy to create a doctype object like this:
using System.Xml.Linq;
// ...
XDocumentType docType = new XDocumentType("myDoctypeName", null, "myown.dtd", null);
You can then build an XML document by creating a root XElement and wrapping the root and doctype in an XDocument like so:
XDocument doc = new XDocument(docType, rootElement);
Upvotes: 2
Reputation: 900
use the DOCTYPE declaration:
<!DOCTYPE root-element SYSTEM "filename">
http://www.w3schools.com/dtd/dtd_intro.asp
http://www.w3schools.com/tags/tag_doctype.asp
Upvotes: 3
Reputation: 519
e.g. for using global variables across several files
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration SYSTEM "sample.dtd">
<myxml>
<node1>&testval;</node1>
</myxml>
sample.dtd:
<!ENTITY testval "1" >
Upvotes: 1