Reputation: 14075
How can I reference online or external DTD in my XML in C#?
string fileName = @"C:\\temp\H2009.xml"; XmlDocument xDoc = new XmlDocument(); xDoc.Load(fileName);
My DTD file is ftp.myPartnerCompany.com/Name.ent
In this .ent file, they define entity like that
<!ENTITY Acaron "Ă"> <!-- latin capital letter A with caron (breve),
U+0102 Latin Extended-A -->
<!ENTITY acaron "ă"> <!-- latin small letter a with caron (breve),
U+0103 Latin Extended-A -->
<!ENTITY Acedil "Ą"> <!-- latin capital letter A with cedilla,
U+0104 Latin Extended-A -->
Now I got the problem like line below since I don't know how to link the xml and .ent file.
Reference to undeclared entity 'Acaron '. Line 4971, position 21.
Thanks in advance.
EDIT
Forget to mention my XML file , it will be like that below.
<?xml version='1.0' encoding='iso-8859-1'?>
<MA>
<Y07 CLID='C737467' KW='BIRANT' KW2='ESINOGLU'>
<Y0747>B&acaron;RANT ES&acaron;NO&Gcaron;LU</Y0747>
<Y0748>MARK KO KYI Sok Kuuluş Sit
KA&Gcaron;ITHASDNE/İTHAILAND
</Y0748>
<Y07>
<MA>
Upvotes: 0
Views: 477
Reputation: 52858
Based on the examples in your question, the .ent file you're pointing to is not a DTD. There aren't any ELEMENT/ATTLIST declarations so the structure is not defined. Without a DTD, your XML can only be well formed (but it isn't).
To reference the file containing all of your ENTITY declarations, you need to use a parameter entity in a DOCTYPE declaration. I don't know C#, so I don't know exactly how you would code this so the output is correct, but here is an example of what your XML output should look like:
<!DOCTYPE MA [
<!ENTITY % ents SYSTEM "name.ent">
%ents;
]>
<MA>
<Y07 CLID="C737467" KW="BIRANT" KW2="ESINOGLU">
<Y0747>B&acaron;RANT ES&acaron;NO&Gcaron;LU</Y0747>
<Y0748>MARK KO KYI Sok Kuuluş Sit KA&Gcaron;ITHASDNE/İTHAILAND </Y0748>
</Y07>
</MA>
Hope this helps.
Upvotes: 1