我有一个复杂的多寄存器文档 xml,我需要在 Perl 中解析它以输出不同的格式。
输入xml:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<result name="response" numFound="58582" start="0">
<doc>
<str name="body">Have a great time at this park!</str><int name="is_park_id">317851</int><str name="ss_image_thumb_small"/>
<str name="title">Playground</str>
</doc>
<doc>
<str name="body">Have a great time at this park!</str><int name="is_park_id">317851</int><str name="ss_image_thumb_small"/>
<str name="title">Playground</str>
</doc>
</result>
</response>
所需的输出格式是:
<?xml version="1.0" encoding="iso-8859-1"?>
<Feed>
<Products>
<Product>
<Description>Have a great time at this park!</Description><ExternalId>PF317851</ExternalId><ImageUrl/>
<Name>Playground</Name>
</Product>
<Product>
<Description>Have a great time at this park!</Description><ExternalId>PF317851</ExternalId><ImageUrl/>
<Name>Playground</Name>
</Product>
</Products>
</Feed>
<str name="body">
应该被视为描述,<int name="is_park_id">
应该被视为<ExternalId>
并且<str name="title">
应该被视为<Name>
。
您能帮助将 XML 格式化为新格式吗?