<?xml version="1.0"?>
<order>
<order_businessid>2</order_businessid>
<order_categoryid>3</order_categoryid>
<product_id>1</product_id>
<product_name1>CreamCheese Cake</product_name1>
<product_price1>4.10</product_price1>
<product_Qty1>1</product_Qty1>
<product_id>3</product_id>
<product_name2>Gujarati unlimited</product_name2>
<product_price2>50.00</product_price2>
<product_Qty2>1</product_Qty2>
<product_id>5</product_id>
<product_name3>Cheese French Frish</product_name3>
<product_price3>4.10</product_price3>
<product_Qty3>1</product_Qty3>
</order>
如何读取这个结构?在PHP中阅读这个XML结构
我想在PHP中输出:
ProduktID 1, has name CreamCheese Cake and it's price is 4.10
ProduktID 3, has name Gujarati unlimited and it's price is 50.00
等..
我知道如何通过元素做到这一点,如果所有信息是一个元素里面,然后我只想循环,获取属性和输出。
但是有了这个,我不知道在所有的,所以希望你能帮助我..
这是一些很糟糕XML。使用相同的名称和组合元素。不要举例,product_name3?只需使用名称,并将所有产品数据作为单个产品元素下的元素/属性进行分组。 – 2011-12-23 15:03:22
这样的XML来自开发人员,他们使用字符串创建XML,而不是DOM方法。只是因为它里面有<>标签并没有使它成为XML。 – 2011-12-23 15:05:03