Php 如何访问此xml字段?
当我卸载此文件时:Php 如何访问此xml字段?,php,xml,xpath,simplexml,Php,Xml,Xpath,Simplexml,当我卸载此文件时: while($row = $updDate->fetch()){//GET FEEDS WHICH UPDATED DATE IS NOT IN DB var_dump($this->soccer->GetAllOddsByFixtureMatchId( array("fixtureMatch_Id"=>$row['FixtureMatch_Id']))); echo $row['FixtureMatch
while($row = $updDate->fetch()){//GET FEEDS WHICH UPDATED DATE IS NOT IN DB
var_dump($this->soccer->GetAllOddsByFixtureMatchId(
array("fixtureMatch_Id"=>$row['FixtureMatch_Id'])));
echo $row['FixtureMatch_Id'];}
它还给我这个提要
object(SimpleXMLElement)[11]
public 'OddsList' =>
object(SimpleXMLElement)[12]
public 'Odds' =>
array (size=37)
0 =>
object(SimpleXMLElement)[13]
...
1 =>
object(SimpleXMLElement)[14]
...
2 =>
object(SimpleXMLElement)[15]
...
3 =>
object(SimpleXMLElement)[16]
...
4 =>
object(SimpleXMLElement)[17]
...
5 =>
object(SimpleXMLElement)[18]
...
6 =>
object(SimpleXMLElement)[19]
...
object(SimpleXMLElement)[11]
public 'OddsList' =>
object(SimpleXMLElement)[12]
public 'Odds' =>
array (size=37)
0 =>
object(SimpleXMLElement)[49]
...
1 =>
object(SimpleXMLElement)[48]
...
2 =>
object(SimpleXMLElement)[47]
...
3 =>
object(SimpleXMLElement)[46]
...
4 =>
object(SimpleXMLElement)[45]
...
5 =>
object(SimpleXMLElement)[44]
...
6 =>
object(SimpleXMLElement)[43]
...
object(SimpleXMLElement)[11]
public 'OddsList' =>
object(SimpleXMLElement)[12]
public 'Odds' =>
array (size=37)
0 =>
object(SimpleXMLElement)[13]
...
1 =>
object(SimpleXMLElement)[14]
...
2 =>
object(SimpleXMLElement)[15]
...
3 =>
object(SimpleXMLElement)[16]
...
4 =>
object(SimpleXMLElement)[17]
...
5 =>
object(SimpleXMLElement)[18]
...
6 =>
object(SimpleXMLElement)[19]
...
我想访问赔率对象,从中获取一些列,并从数据库中的列对其进行比较
当我使用:
->怪人->赔率
,但我需要xpath来满足某些条件。。。因此,我尝试添加这个
->xpath('/OddsList/doffics')
,但它返回空值…xpath对XML有效,因此如果看不到XML,很难说出确切的问题和解决方案。我猜问题是由于默认名称空间的存在。考虑下面的示例XML:
<OddsList xmlns="xmlsoccer.com/">
<Odd>1</Odd>
<Odd>2</Odd>
</OddsList>
输出:
1
2
XML是否有默认名称空间,类似于
xmlns=“foo.bar”
?是的,我想输入:string string首先查看XML的结构,并将其添加到您的问题中:echo$XML->asXML()代码>我比变量转储要干净得多
。然后从那里编写xpath。asXML返回没有xml标记的所有数据,我不确定我是否理解您的意思。我只想比较上传的内容并在我的数据库中添加不同的内容,而不必搜索完整的提要,只要检查diff是否存在,如果确实得到了它,否则继续搜索…要么查看浏览器中得到的源代码,要么执行echo htmlspecialchars($xml->asXML())代码>我找到了解决方案,但谢谢,这在另一种情况下对我有帮助。如果答案不能回答实际问题,请不要接受。相反,在下面用你自己的话添加你的答案,而不仅仅是你自己找到解决方案的评论。
1
2