我有一个如下的xml
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>client</title>
<link>http://www.client.com</link>
<description>gdfgdfgdg</description>
<item>
<id>N10987281A</id>
<title>dfgdfgdfgdfgdg </title>
<link>https://www.client.com/p</link>
<image_link>https://client.com/t_desktop-pdp-v1/v1505732008/N10987281A_1.jpg</image_link>
<condition>new</condition>
<availability>in stock</availability>
<price>31.50 AED</price>
<gtin>27242852310</gtin>
<brand>dfgdgdfg</brand>
<mpn>CDR 50 Shrink</mpn>
<custom_label_2>audio_video</custom_label_2>
<description>fgdfgdfgdfg rgdfgdgdfgdfgdfgdg</description>
<product_type>Electronics & Mobiles/Television & Video</product_type>
<google_product_category>Electronics</google_product_category>
<shipping>
<price>0.00 AED</price>
<country>AE</country>
<service>Standard</service>
</shipping>
</item>
</channel>
</rss>
对于上面的XML,我有下面这样的树节点和从这个getTreenode of the xml得到的树节点
/rss
/rss@version 2.0
/rss/channel
/rss/channel/title client
/rss/channel/link http://www.client.com
/rss/channel/description gdfgdfgdg
/rss/channel/item
/rss/channel/item/id N10987281A
/rss/channel/item/title dfgdfgdfgdfgdg
/rss/channel/item/link https://www.client.com/p
/rss/channel/item/image_link https://client.com/t_desktop-pdp-v1/v1505732008/N10987281A_1.jpg
/rss/channel/item/condition new
/rss/channel/item/availability in stock
/rss/channel/item/price 31.50 AED
/rss/channel/item/gtin 27242852310
/rss/channel/item/brand dfgdgdfg
/rss/channel/item/mpn CDR 50 Shrink
/rss/channel/item/custom_label_2 audio_video
/rss/channel/item/description fgdfgdfgdfg rgdfgdgdfgdfgdfgdg
/rss/channel/item/product_type Electronics & Mobiles/Television & Video
/rss/channel/item/google_product_category Electronics
/rss/channel/item/shipping
/rss/channel/item/shipping/price 0.00 AED
/rss/channel/item/shipping/country AE
/rss/channel/item/shipping/service Standard
现在,如何从上面的树节点本身创建XML
有人能帮我吗
提前谢谢
我添加了评论,因为这比尝试添加完整的描述更容易。你知道吗
但它基本上是从文件中读取树,在解析每一行时创建或移动到各个级别。如果标签中有一个
@
,那么这意味着创建一个属性。。。你知道吗一个稍微微调的循环,它使用正则表达式来提取属性。。。你知道吗
相关问题 更多 >
编程相关推荐