| 
	
 | 
 Posted by Erik Franzιn on 06/16/37 11:32 
Have tried the following code: 
 
<?php 
// Creates an instance of the DOMImplementation class 
$oDomImp = new DOMImplementation; 
 
// Creates a DOMDocumentType instance 
$oDomDtd = $oDomImp->createDocumentType('Document', '',  
'D:/CMAES/Src/dbtree.dtd'); 
 
// Creates a DOMDocument instance 
$oDom = $oDomImp->createDocument("", "Document", $oDomDtd); 
 
// Set other properties 
$oDom->encoding = 'iso-8859-1'; 
 
$oElement = $oDom->createElement('CMAES_Model_DbSection', 'test'); 
$oElement->setAttribute('S_iSectionId', '123'); 
 
// Append the element 
$oDom->documentElement->appendChild($oElement); 
 
// Retrieve and print the document 
echo $oDom->saveXML() . "\n\n"; 
 
// Do validation 
var_dump($oDom->validate()); 
 
// Type node name 
echo "TagName: " . $oDom->getElementById('123')->tagName; 
?> 
 
Using the following DTD as an external file: 
<!ELEMENT Document ANY> 
<!ELEMENT CMAES_Model_DbSection ANY> 
<!ATTLIST CMAES_Model_DbEntry E_iEntryId ID #REQUIRED> 
 
The result is the following: 
 
<?xml version="1.0" encoding="iso-8859-1"?> 
<!DOCTYPE Document SYSTEM "D:/CMAES/Src/dbtree.dtd"> 
<Document><CMAES_Model_DbSection  
S_iSectionId="123">test</CMAES_Model_DbSection></Document> 
 
 
 
Warning:  Syntax of value for attribute S_iSectionId of  
CMAES_Model_DbSection is not valid in <script on line 23 
bool(false) 
TagName: CMAES_Model_DbSection 
 
Now I have some (for me) strange DTD failure due to the error "syntax of  
value for attribute S_iSectionId of CMAES_Model_DbSection is not valid".  
I cannot understand that error. I have missed something, but what?
 
  
Navigation:
[Reply to this message] 
 |