Reply to DomDocument::GetElementById - a workaround with external DTD

Your name:

Reply:


Posted by Erik Franzιn on 09/29/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?

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация