Jump to content

[SOLVED] getElementById STILL not working like it should... :(


448191

Recommended Posts

Argh.

[quote]
Fatal error: Uncaught exception 'Exception' with message 'Node not found.' in E:\John\Sites\CurrentDev\johnkleijn.nl\lib\domxml.class.php:45 Stack trace: #0 E:\John\Sites\CurrentDev\johnkleijn.nl\lib\env.class.php(83): DomXml->getElementById('log_errors') #1 E:\John\Sites\CurrentDev\johnkleijn.nl\lib\backbone.class.php(27): Env->get('log_errors') #2 E:\John\Sites\CurrentDev\johnkleijn.nl\index2.php(6): Backbone->__construct('transitional', 'iso-8859-1') #3 {main} thrown in E:\John\Sites\CurrentDev\johnkleijn.nl\lib\domxml.class.php on line 45[/quote]

As you can see by looking at the backtrace, the exeption is thrown from DomXml->getElementById.

[b]DomXml->getElementById('log_errors')[/b]
[code]<?php
public function getElementById($id) {
if($this->domDoc->validate()) {
if(!$node = $this->domDoc->getElementById($id)) {
throw new Exception('Node not found.');
}
else {
return $node;
}
}
else {
return false;
}
}
?>[/code]

While:
[code]<error_flag id="log_errors">true</error_flag>[/code]
and the attribute id is specified to be of type ID:
[code]<!ENTITY % idattr "id ID #IMPLIED" >
<!ELEMENT error_flag (#PCDATA)>
<!ATTLIST error_flag  %idattr; >[/code]

Obviously, the XML file validates, or the exeption could never have been thrown. I just don't get why I don't get the freakin node to return!
Link to comment
Share on other sites

What the $#!@^&%? is going on?

I messed up the DTD intentionally to see what would happen:

[code]<!-- <!ELEMENT error_flag (#PCDATA)> -->
<!ATTLIST error_flag id ID #REQUIRED > [/code]

When tested with Dreamweavers validation it retruns the correct error: "unknown element error_flag" (before it didn't return anything), but when I try to run the test script, I get NO validation errors, just the same exeption! That doesn't make any sense!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.