Skip to content
Advertisement

XML PHP Format Setup

Is there a why to do this? I’m new on create DomDocument. Thank you

<!DOCTYPE Data SYSTEM "http://data.data.org/schemas/data/1.234.1/data.dtd"> <Data payloadID = "123123123131231232323" timestamp = "2015-06-10T12:59:09-07:00">

JavaScript

Advertisement

Answer

Here are two ways in DOM to create a new document in PHP. If you don’t need the DTD you can directly create an instance of the DOMDocument class.

JavaScript

Output:

JavaScript

For a document with a DTD your approach was correct.

JavaScript

Output:

JavaScript

After the initial bootstrap you use methods of the $document to create nodes and append them.

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement