对方给了一个页面为 abc.php,我点击右键查看源代码,得到的内容如下
<root>
<SecondHouse id="217045" userid="jtzy" password="123456" del="0">
<House>3-2-2</House>
<AddDate>2010-11-2 16:35:08</AddDate>
</SecondHouse>
<SecondHouse id="217042" userid="jtzy" password="123456" del="0">
<House>3-2-1</House>
<AddDate>2010-11-2 16:30:56</AddDate>
</SecondHouse>
<SecondHouse id="217041" userid="jtzy" password="123456" del="0">
<House>2-2-1</House>
<AddDate>2010-11-2 16:19:06</AddDate>
</SecondHouse>
</root>
要求:如何通过对方给的url(abc.php),把对方页面中的 House AddDate 这二个字段内容放入二维数组中,thanks
<root>
<SecondHouse id="217045" userid="jtzy" password="123456" del="0">
<House>3-2-2</House>
<AddDate>2010-11-2 16:35:08</AddDate>
</SecondHouse>
<SecondHouse id="217042" userid="jtzy" password="123456" del="0">
<House>3-2-1</House>
<AddDate>2010-11-2 16:30:56</AddDate>
</SecondHouse>
<SecondHouse id="217041" userid="jtzy" password="123456" del="0">
<House>2-2-1</House>
<AddDate>2010-11-2 16:19:06</AddDate>
</SecondHouse>
</root>
要求:如何通过对方给的url(abc.php),把对方页面中的 House AddDate 这二个字段内容放入二维数组中,thanks
$b=Preg_match("/????/i",$A);
不是吧,php版本多少???
$xml =<<<doc
<root>
<SecondHouse id="217045" userid="jtzy" password="123456" del="0">
<House>3-2-2</House>
<AddDate>2010-11-2 16:35:08</AddDate>
</SecondHouse>
<SecondHouse id="217042" userid="jtzy" password="123456" del="0">
<House>3-2-1</House>
<AddDate>2010-11-2 16:30:56</AddDate>
</SecondHouse>
<SecondHouse id="217041" userid="jtzy" password="123456" del="0">
<House>2-2-1</House>
<AddDate>2010-11-2 16:19:06</AddDate>
</SecondHouse>
</root>
doc;
preg_match_all('#<house>(.*)</house>\s*<adddate>(.*)</adddate>#isU', $xml, $m);
unset($m[0]);
print_r($m);
1 为何我换了下面的一段xml内容就运行不了,格式还是utf-8,如何才能运行下面的xml内容
<root>
<SecondHouse id="217155" userid="jtzy" password="123456" del="0">
<City>南昌</City>
<Area>莲塘</Area>
<BH>XXH217155</BH>
<Simple>澄湖北路梦里水乡</Simple>
<House>2-1-1</House>
<Number></Number>
<Kind>商品房</Kind>
<Floor>6/4</Floor>
<Sunny>南北</Sunny>
<BuildArea>101.96</BuildArea>
<BuildTime></BuildTime>
<Fitment>简装</Fitment>
<FitmentTime>0</FitmentTime>
<Layout></Layout>
<Bround></Bround>
<ManagerPrice></ManagerPrice>
<Price>50</Price>
<UnitPrice></UnitPrice>
<Note></Note>
<Tel>0791-7186688;7160778;7572099</Tel>
<Linkman>信息部</Linkman>
<AddDate>2010-11-3 13:30:03</AddDate>
</SecondHouse>
<SecondHouse id="217152" userid="jtzy" password="123456" del="0">
<City>南昌</City>
<Area>红谷滩</Area>
<BH>TYS217152</BH>
<Simple>绿茵路红谷世纪花园</Simple>
<House>2-2-1</House>
<Number></Number>
<Kind>商品房</Kind>
<Floor>11/3</Floor>
<Sunny>南北</Sunny>
<BuildArea>102</BuildArea>
<BuildTime></BuildTime>
<Fitment>精装</Fitment>
<FitmentTime>0</FitmentTime>
<Layout></Layout>
<Bround></Bround>
<ManagerPrice></ManagerPrice>
<Price>85</Price>
<UnitPrice></UnitPrice>
<Note></Note>
<Tel>6530038/15270916366</Tel>
<Linkman>桃苑店</Linkman>
<AddDate>2010-11-3 12:14:01</AddDate>
</SecondHouse>
<SecondHouse id="217151" userid="jtzy" password="123456" del="0">
<City>南昌</City>
<Area>青山湖区</Area>
<BH>TYS217151</BH>
<Simple>解放西路国药厂宿舍</Simple>
<House>2-1-1</House>
<Number></Number>
<Kind>商品房</Kind>
<Floor>7/7</Floor>
<Sunny>南北</Sunny>
<BuildArea>68</BuildArea>
<BuildTime></BuildTime>
<Fitment>简装</Fitment>
<FitmentTime>0</FitmentTime>
<Layout></Layout>
<Bround></Bround>
<ManagerPrice></ManagerPrice>
<Price>34</Price>
<UnitPrice></UnitPrice>
<Note>另送一个8平米的储藏间</Note>
<Tel>6530038/15270916366</Tel>
<Linkman>桃苑店</Linkman>
<AddDate>2010-11-3 12:11:49</AddDate>
</SecondHouse>
</root>
preg_match_all('/<Simple>(.*)<\/Simple>/i',$xml,$Simple);//得到页面中BuildArea字段所有值
print_r($Simple[1]);