How to add a DOCTYPE in an XML filek with DOMDocument

AitorEG
Member Posts: 342
iHi everyone?
How can i add this line to an XML file, using DOMDocument methods?
For adding this
I use:
XMLDomInst:= XMLDocOut.createProcessingInstruction('xml','version="1.0" encoding="iso-8859-1" standalone="no"');
Which method could be used for adding the DOCTYPE?
Thank you very much!!
How can i add this line to an XML file, using DOMDocument methods?
<!DOCTYPE ESHIPPER SYSTEM 'https://XXXXXXXXXXXXXXXXX.dtd'>
For adding this
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
I use:
XMLDomInst:= XMLDocOut.createProcessingInstruction('xml','version="1.0" encoding="iso-8859-1" standalone="no"');
Which method could be used for adding the DOCTYPE?
Thank you very much!!
0
Answers
-
Hello,
Check if this could help https://stackoverflow.com/questions/9882648/how-to-add-a-document-type-to-a-new-xml-file-in-c-sharp0 -
Hello,
Check if this could help https://stackoverflow.com/questions/9882648/how-to-add-a-document-type-to-a-new-xml-file-in-c-sharp
Thanks for your answer. i was using that, in this way:docTypeXMlNode := XMLDocOut.CreateDocumentType(ESHIPPER SYSTEM 'https://iconnection.tnt.com/ShipperDTD2.0/EshipperIN2.dtd');
where XMLDocOut is a DOMDocument. May be that is why it shows me he error that CreateDocumentType method doesn't exist. It is a "'Microsoft XML, v6.0'.DOMDocument" instead of a properly said XMLDocument. Any clues for this type of object?
0 -
These are the method that can be used on this objet:
https://msdn.microsoft.com/en-us/library/ms757828(v=vs.85).aspx
No hints about adding the DOCTYPE???0 -
Hello @AitorEG
Check here. It saysThe DocumentType node must also be inserted before the root element of the XmlDocument (if the document already has a root element, you cannot add a DocumentType node).var xDocument = new XDocument( new XDocumentType( "smil", "-//W3C//DTD SMIL 2.0//EN", "http://www.w3.org/2001/SMIL20/SMIL20.dtd", null ), new XElement("Root") // --->Root is created after DocType );
Your code should do something like this:doctype = XMLdoc.CreateDocumentType("book", "http://mydtd.com/book.dtd", "book.dtd", null); XMLdoc.AppendChild(doctype);
Maybe someone can better help you if you share your code ?0 -
Hi @NavNab
This is my code:companyInfo.GET; CREATE(XMLDocOut,FALSE,TRUE); XMLDocOut.async(FALSE); XMLDomInst:= XMLDocOut.createProcessingInstruction('xml','version="1.0" encoding="iso-8859-1" standalone="no"'); XMLDocOut.appendChild(XMLDomInst); docTypeXMlNode := XMLDocOut.createDocType('ESHIPPER' ,null, 'https://XXXXXXXXXX/EYYYYY.dtd'); EshiperXMlNode := XMLDocOut.createNode(1,'ESHIPPER',''); XMLDocOut.appendChild(EshiperXMlNode);
It looks like finally don't need to insert the doctype declaration, but I have to confirm that with the system owner later this morning. But anyway, it seems that the differences betwen XMLDocument and DOMDocument will create me a few more problem with the comunication, and when using http requests...
Thank you again, really appreciate!!!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions