PHPquery 在不应该删除标记标签名称的大写时

PHPquery is removing capitalization for markup tag names when it shouldn't

我正在与亚马逊 api(s) 合作,在 PHP 查询中创建新文档时遇到了 运行 问题。我正在使用版本 0.9.5

var_dump($innerHTML);
$php_query=\phpQuery::newDocument("<root>".$innerHTML."</root>");
var_dump($php_query->html());

给出读数:

    string '<TotalOffers>2</TotalOffers><TotalOfferPages>1</TotalOfferPages>   <MoreOffersUrl>https://www.amazon.co.uk/gp/offer-listing/B01KI13K0W%3FSubscriptionId%3DAKIAICCWYPWR3A76YQDQ%26tag%3D8496-5230-2708%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB01KI13K0W</MoreOffersUrl><Offer>
  <Merchant>
    <Name>Amazon.co.uk</Name>
  </Merchant>
  <OfferAttributes>
    <Condition>New</Condition>
  </OfferAttributes>
  <OfferListing>
    <OfferListingId>ZUHqmK4tgaBMBcOsWWSBV%2B%2FwXbnd%2BSYg58EFdjcH93Ayh%2FnSp741DyflKxdwL7w7k4O7nJ9zTBkxRNymmCq%2BNtgwHMXrFlFZRtfv0VL%2BBm8%3D</OfferListingId>
    <Price>
      <Amount>21999</Amount>
      <CurrencyCode>GBP</CurrencyCode>
      <FormattedPrice>£219.99</FormattedPrice>
    </Price>
    <Availability>Usually dispatched within 24 hours</Availability>
    <AvailabilityAttributes>
      <AvailabilityType>now</AvailabilityType>
      <MinimumHours>0</MinimumHours>
      <MaximumHours>0</MaximumHours>
    </AvailabilityAttributes>
    <IsEligibleForSuperSaverShipp'... (length=2055)

还有...

string '<root><totaloffers>2</totaloffers><totalofferpages>1</totalofferpages><moreoffersurl>https://www.amazon.co.uk/gp/offer-listing/B01KI13K0W%3FSubscriptionId%3DAKIAICCWYPWR3A76YQDQ%26tag%3D8496-5230-2708%26linkCode%3Dxm2%26camp%3D2025%26creative%3D12734%26creativeASIN%3DB01KI13K0W</moreoffersurl><offer><merchant><name>Amazon.co.uk</name></merchant><offerattributes><condition>New</condition></offerattributes><offerlisting><offerlistingid>ZUHqmK4tgaBMBcOsWWSBV%2B%2FwXbnd%2BSYg58EFdjcH93Ayh%2FnSp741DyflKxdwL7w7k4O7nJ9zTBkxRNymmCq%2BNtgwHMXrFlFZRtfv0VL%2BBm8%3D</offerlistingid><price><amount>21999</amount><currencycode>GBP</currencycode><formattedprice>£219.99</formattedprice></price><availability>Usually dispatched within 24 hours</availability><availabilityattributes><availabilitytype>now</availabilitytype><minimumhours>0</minimumhours><maximumhours>0</maximumhours></availabilityattributes><iseligibleforsupersavershipping>1</iseligibleforsupersavershipping><iseligibleforprime>1</iseligibleforprime></offerlisting>'... (length=1846)

如您所见,标签 capitalization 已丢失。 这是 PHPquery 的默认行为吗?如果是,是否有任何方法可以维护标签 capitalization?

\phpQuery::newDocument 仍然没有 <root> 标签。

(请注意,这个问题的目的纯粹是关于标签在使用 \phpQuery::newDocument 时失去 capitalization 而不是在这种情况下使用 PHPquery 的功效)

谢谢。

我们将不胜感激 :) .

编辑:已回答(感谢您的帮助!)\phpQuery::newDocument() 不区分大小写,应该使用 \phpQuery::newDocumentXML() 来维护大小写

变化:

var_dump($innerHTML);
$php_query=\phpQuery::newDocument("<root>".$innerHTML."</root>");
var_dump($php_query->html());

至:

var_dump($innerHTML);
$php_query=\phpQuery::newDocumentXML("<root>".$innerHTML."</root>");
var_dump($php_query->html());

因为 HTML 对其标签名称不区分大小写,而 XML 则不区分大小写。因此 \phpQuery::newDocument() 不区分大小写并且不保持标签名称的大写。而应使用 \phpQuery::newDocumentXML() 来维护标签名称的大小写。