/    Sign up×
Community /Pin to ProfileBookmark

DOMDoument – Strict to DOCType?

I am passing HTML source code that i have retrieved from a webpage into a DOM Document object using:

[code]
$dom = new domDocument;
$dom->loadHTML($source);
[/code]

The problem i am getting is when i run the code i get errors such as:

ID week-1 already defined in Entity, line: 126.
htmlParseEntityRef: no name in Entity, line: 303.

Am i right in thinking this is DOMDocument having problems parsing the source I’ve acquired?

If so, is DOMDocument strict to the DOCTYPE specified in the HTML? as i have checked this webpage with W3C and the page contains 303 errors when checking against the DOCTYPE specified.

I feel the DOCTYPE errors may be causing my problems, but im unsure.

I would appreciate your thoughts,

Thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SrWebDeveloperNov 25.2009 — Good assumption.

Using loadHTML() automagically sets the doctype property of your DOMDocument instance(to the doctype in the html, or defaults to 4.0 Transitional). If you set the doctype with DOMImplementation it will be overridden.
×

Success!

Help @gsc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...