php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53314 simplexml_load_string can't parse all tags
Submitted: 2010-11-15 07:47 UTC Modified: 2010-11-15 16:38 UTC
From: 122363686 at qq dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.3.3 OS: windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: 122363686 at qq dot com
New email:
PHP Version: OS:

 

 [2010-11-15 07:47 UTC] 122363686 at qq dot com
Description:
------------
run this php,i can't find

<textEntryInteraction>9999</textEntryInteraction>

&

<textEntryInteraction>14285</textEntryInteraction>

in the result.

Test script:
---------------
$string ='<assessmentItem>
  <item Type="assessmentItem">
    <prompt>中广网快讯(记者张棉棉)据中国之声《央广新闻》报道,国家统计局刚刚公布了最新消费者物价指数和生产者物价指数。</prompt>
  </item>
  
  <item Type="assessmentItem">
    <prompt>0月份居民消费价格指数同比上涨4.4%</prompt>
    <simpleChoice correctResponse="False">1,涨幅比9月份扩大0.8个百分点。</simpleChoice>
    <simpleChoice correctResponse="False">其中,城市上涨4.2%,农村上涨4.7%,食品价格上涨10.1%</simpleChoice>
    <simpleChoice correctResponse="True">非食品价格上涨1.6%,消费品价格上涨5%,服务项目价格上涨2.5%。</simpleChoice>
  </item>
  
  <item Type="assessmentItem">
    <prompt>10月份工业品出厂价格同比上涨5.0%,</prompt>
    <simpleChoice correctResponse="True">
      涨幅比9月份扩大<textEntryInteraction>9999</textEntryInteraction>百分点。
    </simpleChoice>
    <simpleChoice correctResponse="False"> 此外,社会消费品零售总额保持较快增长,</simpleChoice>
    <simpleChoice correctResponse="True">
      社会消费品零售总额
      <textEntryInteraction>14285</textEntryInteraction>
      亿元,同比增长18.6%,比9月份回落0.2个百分点。
    </simpleChoice>
  </item>
  
  <item Type="assessmentItem">
    <prompt>工业生产平稳增长。10月份规模以上工业增加值同比增长13.1%,比9月份回落0.2个百分点。1至10月规模以上工业增加值同比增长16.1%,比1至9月份回落0.2个百分点。1至10月城镇固定资产投资187556亿元,同比增长24.4%,1至9月份回落0.1个百分点。</prompt>
    <textEntryInteraction/>
  </item>
   
</assessmentItem>
';

$xml = simplexml_load_string($string); 
echo '<pre>';
print_r($xml);

Expected result:
----------------
Please parse all tags.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-15 16:38 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-11-15 16:38 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is a known detail when printing the SimpleXMLElement using print_r(). But the element is there.

You can check them using:
var_dump($xml->xpath('//textEntryInteraction'));

There are others reported related to this, e.g. bug #44973

But this is not a PHP bug, thanks.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Dec 06 16:03:59 2022 UTC