Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to load XML document with DOMElements case-folded?
    primarykey
    data
    text
    <p>I'm loading an XML document with <a href="http://us.php.net/domdocument" rel="nofollow">DOMDocument</a>'s <a href="http://us.php.net/manual/en/domdocument.loadxml.php" rel="nofollow">loadXML function</a>. There doesn't appear to be any <a href="http://us.php.net/manual/en/libxml.constants.php" rel="nofollow">options</a> to case fold DOMElement's tagName and attribute names.</p> <p>I need to treat the XML document as being case-insensitive so this should be considered invalid (name and NAME should be the same, not unique):</p> <pre><code>&lt;input name="field" NAME="field2" /&gt; </code></pre> <p>Likewise the getAttribute/setAttribute functions should treat "NAME" AND "name" as the same attribute.</p> <p>The <a href="http://us2.php.net/manual/en/book.xml.php" rel="nofollow">xml parser functions</a> appear to have this functionality through the <a href="http://us2.php.net/manual/en/function.xml-parser-set-option.php" rel="nofollow">xml_parser_set_option</a> function through the "XML_OPTION_CASE_FOLDING" constant. But DOMDocument and these functions appear to be mutually exclusive, with the only similarity being they both use libxml2 behind the scenes.</p> <p>So is there any way to force DOMDocument to case-fold? Are there any drop in replacements that use the xml parser functions? I'm looking to avoid using anything that uses regular expressions. The appeal of DOMDocument is the object vs procedural design.</p> <p>Normally the XML document nodes should be lowercase anyway. But I'd like my code to still work if someone capitalizes something and transform it to lowercase after parsing the document.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload