使用PIG拉丁语加载XML
我有一个多级xml,但我找不到如何加载它的任何示例 XML文件:使用PIG拉丁语加载XML,xml,apache-pig,Xml,Apache Pig,我有一个多级xml,但我找不到如何加载它的任何示例 XML文件: <?xml version="1.0" encoding="UTF-8" ?> <Feed xmlns="http://www.xx.com/PRR/ProductFeed/1.0" name="xx" incremental="false" extractDate="2014-04-22T11:00:00.
<?xml version="1.0" encoding="UTF-8" ?>
<Feed xmlns="http://www.xx.com/PRR/ProductFeed/1.0"
name="xx"
incremental="false"
extractDate="2014-04-22T11:00:00.000000"><Categories><Category> <ExternalId>2_5</ExternalId><ParentExternalId></ParentExternalId><Name><![CDATA[Baby]]></Name><CategoryPageUrl>http://www.xx.com/en-US/Clearance/Baby-0-3yrs-Clothing.html</CategoryPageUrl></Category><Category><ExternalId>2_3</ExternalId><ParentExternalId></ParentExternalId><Name><![CDATA[Boys 1½-12yrs]]></Name><CategoryPageUrl>http://www.xx.com/en-US/Clearance/Boys-1H-12yrs-Clothing.html</CategoryPageUrl></Category></Categories>
<Products><Product><ExternalId>78094</ExternalId><Name><![CDATA[Sleep Bag]]></Name><Description><![CDATA[A cover they can't throw off in the night. Pure cotton with one of our uniquely lovely prints. In its own gift box. An ultra thoughtful, luxurious present.]]></Description><Brand>xx</Brand><CategoryExternalId>1_5_1</CategoryExternalId><ProductPageUrl>http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094/Baby-0-3yrs-Sleep-Bag.html</ProductPageUrl><ImageUrl>http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg</ImageUrl><SwatchImageUrl>http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg</SwatchImageUrl><Price>54.0000</Price><Wasprice>54.0000</Wasprice><ManufacturerPartNumber></ManufacturerPartNumber><EAN></EAN><Colours><Variation><Tier2>MUL</Tier2><Tier2Descr><![CDATA[Multi Elephant Party]]></Tier2Descr><Tier2Url>http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094-MUL/Baby-0-3yrs-Multi-Elephant-Party-Sleep-Bag.html</Tier2Url><Tier2ImageUrl>http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg</Tier2ImageUrl><Tier3>03 06</Tier3><Tier3Descr><![CDATA[3-6m]]></Tier3Descr><StockStatus>-2</StockStatus><SwatchUrl>http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg</SwatchUrl></Variation><Variation><Tier2>MUL</Tier2><Tier2Descr><![CDATA[Multi Elephant Party]]></Tier2Descr><Tier2Url>http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094-MUL/Baby-0-3yrs-Multi-Elephant-Party-Sleep-Bag.html</Tier2Url><Tier2ImageUrl>http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg</Tier2ImageUrl><Tier3>06 18</Tier3><Tier3Descr><![CDATA[6-18m]]></Tier3Descr> <StockStatus>-2</StockStatus> <SwatchUrl>http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg</SwatchUrl> </Variation></Colours></Product>
</Products>
</Feed>
2_5http://www.xx.com/en-US/Clearance/Baby-0-3yrs-Clothing.html2_3http://www.xx.com/en-US/Clearance/Boys-1H-12yrs-Clothing.html
78094\\n\\s*(.*)\\n\\s*(.*)\\n\\s*(.*)\\n\\s*(.*)\\n\\s*)
as(外部\u id:chararray,父\u外部\u id:chararray,名称:chararray,类别页面URL:chararray);
如何加载上述xml
提前谢谢
更新:如果我在每个字段后面放一个换行符,那么我可以读取数据。。。我怎样才能解决这个问题?其他工具不需要换行符,我无法更改源数据
格式化的xml:
<?xml version="1.0" encoding="UTF-8" ?>
<Feed xmlns="http://www.xx.com/PRR/ProductFeed/1.0"
name="xx"
incremental="false"
extractDate="2014-04-22T11:00:00.000000">
<Categories>
<Category>
<ExternalId>2_5</ExternalId>
<ParentExternalId></ParentExternalId>
<Name>Baby</Name>
<CategoryPageUrl>http://www.xx.com/en-US/Clearance/Baby-0-3yrs-Clothing.html</CategoryPageUrl>
</Category>
<Category>
<ExternalId>2_3</ExternalId>
<ParentExternalId></ParentExternalId>
<Name>Boys 1½-12yrs</Name>
<CategoryPageUrl>http://www.xx.com/en-US/Clearance/Boys-1H-12yrs-Clothing.html</CategoryPageUrl>
</Category>
</Categories>
<Products>
<Product>
<ExternalId>78094</ExternalId>
<Name>Sleep Bag</Name>
<Description>A cover they can't throw off in the night. Pure cotton with one of our uniquely lovely prints. In its own gift box. An ultra thoughtful, luxurious present.</Description>
<Brand>xx</Brand>
<CategoryExternalId>1_5_1</CategoryExternalId>
<ProductPageUrl>http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094/Baby-0-3yrs-Sleep-Bag.html</ProductPageUrl>
<ImageUrl>http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg</ImageUrl>
<SwatchImageUrl>http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg</SwatchImageUrl>
<Price>54.0000</Price>
<Wasprice>54.0000</Wasprice>
<ManufacturerPartNumber></ManufacturerPartNumber>
<EAN></EAN>
<Colours>
<Variation>
<Tier2>MUL</Tier2>
<Tier2Descr>Multi Elephant Party</Tier2Descr>
<Tier2Url>http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094-MUL/Baby-0-3yrs-Multi-Elephant-Party-Sleep-Bag.html</Tier2Url>
<Tier2ImageUrl>http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg</Tier2ImageUrl>
<Tier3>03 06</Tier3>
<Tier3Descr>3-6m</Tier3Descr>
<StockStatus>-2</StockStatus>
<SwatchUrl>http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg</SwatchUrl>
</Variation>
<Variation>
<Tier2>MUL</Tier2>
<Tier2Descr>Multi Elephant Party</Tier2Descr>
<Tier2Url>http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094-MUL/Baby-0-3yrs-Multi-Elephant-Party-Sleep-Bag.html</Tier2Url>
<Tier2ImageUrl>http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg</Tier2ImageUrl>
<Tier3>06 18</Tier3>
<Tier3Descr>6-18m</Tier3Descr>
<StockStatus>-2</StockStatus>
<SwatchUrl>http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg</SwatchUrl>
</Variation>
</Colours>
</Product>
</Products>
</Feed>
2_5
宝贝
http://www.xx.com/en-US/Clearance/Baby-0-3yrs-Clothing.html
2_3
男孩1½-12岁
http://www.xx.com/en-US/Clearance/Boys-1H-12yrs-Clothing.html
78094
睡袋
一个他们不能在晚上扔掉的掩护。纯棉面料,印有我们独一无二的可爱印花。在它自己的礼品盒里。一份极其周到、奢华的礼物。
xx
1_5_1
http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094/Baby-0-3yrs-Sleep-Bag.html
http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg
http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg
54
54
骡子
多象党
http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094-MUL/Baby-0-3yrs-Multi-Elephant-Party-Sleep-Bag.html
http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg
03 06
3-6米
-2
http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg
骡子
多象党
http://www.xx.com/en-US/Baby-0-3yrs-Accessories/78094-MUL/Baby-0-3yrs-Multi-Elephant-Party-Sleep-Bag.html
http://www.xx.com/productimages/productThumb160x207/14USPR_78094_MUL.jpg
06 18
6-18米
-2
http://www.xx.com/productimages/grsw/14USPR_78094_MUL_s.jpg
您的正则表达式字符串似乎需要一个新行字符:
\\n\\s*
将此更改为[\n\s]*应该可以使用我可以格式化xml,现在可以读取类别,但无法读取产品,因为其中包含嵌入的变体。如何加载此xml?
\\n\\s*