[英]Using PHP to Parse complex XML
I need to parse a big XML file, to import some information in to a db, but I'm having troubles accessing all the data inside the XML. 我需要解析一个大的XML文件,以将一些信息导入到db中,但是在访问XML内部的所有数据时遇到了麻烦。
My XML file is something like this: 我的XML文件是这样的:
http://pastebin.com/BzZx0D06 http://pastebin.com/BzZx0D06
If I do this: 如果我这样做:
print_r($xml);
I obtain something like: 我得到类似的东西:
http://pastebin.com/3AgSryDZ http://pastebin.com/3AgSryDZ
For every record I'd like to access to the name attribute of card tag, and to the name tag below (italian traslation). 对于每条记录,我都想访问card标签的name属性,以及下面的name标签(意大利语翻译)。
To access the name attribute I can use: 要访问名称属性,我可以使用:
echo (string)$xml->card[0]->attributes()->name;
That Works, but I can't find a way to access to the translated name. 那行得通,但是我找不到访问翻译后名称的方法。
For Example, for the first element I have: 例如,对于第一个元素,我有:
echo (string)$xml->card[0]->attributes()->name;
that return 那回
A Display of My Dark Power
But I can't find the way to get the "Uno Sfoggio del Mio Potere Oscuro" Value. 但我找不到获得“ Uno Sfoggio del Mio Potere Oscuro”价值的方法。
我认为您可以这样访问翻译:
echo (string)$xml->card[0]->set->name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.