Skip to content
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 · Fixed by #64
Closed

Tag names with strange capitalisation #63

zhaofengli opened this issue Nov 23, 2014 · 0 comments · Fixed by #64

Comments

@zhaofengli
Copy link
Contributor

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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant