Why when I send XML to PHP are the nodes lowercase, but when I parse them in PHP they are uppercase?

后端 未结 1 1525
悲&欢浪女
悲&欢浪女 2021-01-28 07:07

This is a follow up question to this answer:

How do I parse XML from PHP that was sent to the server as text/xml?

JavaScript/jQuery:

var xmlDoc =         


        
相关标签:
1条回答
  • 2021-01-28 07:44

    Your PHP script receives <items><ITEM>My item!</ITEM></items> as input. Try

    <?php
    $xml_text = file_get_contents("php://input");
    file_put_contents('test.log.txt', $xml_text);
    if you think this isn't so.

    xmlDoc is an xml document, but the result of jQuery( "<item>My item!</item>" ) isn't. Along the way jQuery uses .nodeName which behaves like .tagName for elements.
    https://developer.mozilla.org/en/DOM/element.tagName says:

    In XML (and XML-based languages such as XHTML), tagName preserves case. In HTML, tagName returns the element name in the canonical uppercase form. The value of tagName is the same as that of nodeName.

    0 讨论(0)
提交回复
热议问题