New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag names with strange capitalisation #63

Closed
zhaofengli opened this Issue Nov 23, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@zhaofengli
Contributor

zhaofengli commented Nov 23, 2014

The parser fails when it encounters a tag name with strange capitalisation (e.g. <Title>, <titlE>, etc). For example, this script

<?php
require_once __DIR__ . "/vendor/autoload.php";
$html = <<< 'HERE'
<!doctype html>
<html>
<head>
        <Title>Hello, world!</Title>
</head>
<body></body>
</html>
HERE;
$parser = new Masterminds\HTML5;
$dom = $parser->loadHTML( $html );

echo "== HTML5 rendering ==\n";
echo $parser->saveHTML( $dom );

echo "== XPath queries ==\n";
$xpath = new DOMXPath( $dom );
$xpath->registerNamespace( "x", "http://www.w3.org/1999/xhtml" );
echo "=== Value of <title> ===\n";
echo $xpath->query( "//x:title" )->item( 0 )->nodeValue;

outputs:

== HTML5 rendering ==
<!DOCTYPE html>
<html><head>
    <title>Hello, world!&lt;/Title&gt;
&lt;/head&gt;
&lt;body&gt;&lt;/body&gt;
&lt;/html&gt;</title></head></html>
== XPath queries ==
=== Value of <title> ===
Hello, world!</Title>
</head>
<body></body>

The HTML supplied is valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment