XML数据到平面数组

XML数据到平面数组,xml,arrays,flat,Xml,Arrays,Flat,我有一个(也许)简单的问题,但我目前无法解决它 我有一个格式化的XML字符串,如下所示: <?xml version="1.0" encoding="utf-8"?> <e5Notification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xml.element5.com/2.3/ordernotification.xsd"> &

我有一个(也许)简单的问题,但我目前无法解决它

我有一个格式化的XML字符串,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<e5Notification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xml.element5.com/2.3/ordernotification.xsd">
<OrderNotification>
<Purchase>
<PurchaseId>391489835</PurchaseId>
<PurchaseDate>2011-09-17T11:37:52</PurchaseDate>
<PurchaseOrigin>online</PurchaseOrigin>
<PaymentCompleteDate>2011-09-17T11:37:52</PaymentCompleteDate>
<PaymentStatus>test payment arrived</PaymentStatus>
<CustomerData>
<BillingContact>
<LastName>User</LastName>
<FirstName>Test</FirstName>
<Email>nix@inter.net</Email>
<Address>
<Street1>Musterweg 123</Street1>
<City>Musterhausen</City>
<PostalCode>12345</PostalCode>
<CountryId>DE</CountryId>
<Country>Deutschland</Country>
</Address>
</BillingContact>
<DeliveryContact>
<LastName>User</LastName>
<FirstName>Test</FirstName>
<Email>nix@inter.net</Email>
<Address>
<Street1>Musterweg 123</Street1>
<City>Musterhausen</City>
<PostalCode>12345</PostalCode>
<CountryId>DE</CountryId>
<Country>Deutschland</Country>
</Address>
</DeliveryContact>
<CustomerPaymentData>
<PaymentMethod>Visa</PaymentMethod>
<Currency>EUR</Currency>
</CustomerPaymentData>
<Language>Deutsch</Language>
<RegName>Test User</RegName>
<SubscribeNewsletter>false</SubscribeNewsletter>
</CustomerData>
<PurchaseItem>
<RunningNo>1</RunningNo>
<ProductId>1234567896</ProductId>
<ProductName>Test-Product</ProductName>
<NotificationNo>0</NotificationNo>
<DeliveryType>Electronically</DeliveryType>
<Currency>EUR</Currency>
<Quantity>1</Quantity>
<ProductSinglePrice>192.44</ProductSinglePrice>
<VatPct>19.00</VatPct>
<Discount>0.00</Discount>
<ExtendedDownloadPrice>0.00</ExtendedDownloadPrice>
<ManuelOrderPrice>0.00</ManuelOrderPrice>
<ShippingPrice>0.00</ShippingPrice>
<ShippingVatPct>19.00</ShippingVatPct>
<Subscription>
<Interval>Monthly without end</Interval>
</Subscription>
</PurchaseItem>
</Purchase>
</OrderNotification>
</e5Notification>

391489835
2011-09-17T11:37:52
在线 的
2011-09-17T11:37:52
测试费到了
使用者
测验
nix@inter.net
Musterweg 123
穆斯特豪森
12345
判定元件
德国
使用者
测验
nix@inter.net
Musterweg 123
穆斯特豪森
12345
判定元件
德国
签证
欧元
德国
测试用户
错误的
1.
1234567896
测试产品
0
电子地
欧元
1.
192.44
19
0
0
0
0
19
月刊
我想把它转换成一个尽可能平坦的简单数组

我曾试图寻找可能的,几乎匹配的解决方案,以解决我自己的S-O,但也许我有一个封锁在我的头immo


也许有人能帮我。

这似乎是一个令人难以置信的复杂问题,所以我可能不理解这个问题。答案是解析xml,将其存储在
数组[]
中,因此(使用伪C表示法):


这开始解决你的问题了吗?还是我错了?

什么是“尽可能平坦”呢?嗯,你为什么要首先将数据平坦化?另外,我不太确定我是否理解这个问题。通常,您只需将XML解析为DOM树并对其进行操作。为什么这对你不起作用?@长颈鹿船长想要的不是
text
,而是
text
。我不知道你为什么要这么做。这帮了我一臂之力^^^我想用复杂的方法来解决它。谢谢大家!@Marcel——如果答案有帮助,请考虑通过点击大纲旁边的复选标记来接受它。谢谢我的名誉谢谢你:-)
array[0]:   struct OrderNotification, consisting of one or more
              struct Subscription, where each subscription has a collection of
                struct Purchase, and each Purchase has some
                  struct PurchaseItem;
array[1]:   same as array[0]
array[2]:   same as array[0]

usw.