如何在xmlinputformat hadoop中为属性提供xml start标记

时间:2015-01-04 04:59:43

标签: xml hadoop

我想解析hadoop中的xml文件。它包含像

这样的标签
<article name="..." year="...." /> 

如果我在article中将xmlinputformat start_tag_key作为我的开始标记,则它不会识别文章标记,因为我的文件包含带有属性的文章标记。

如何在start_tag_key中为上述文章标记指定xmlinputformat

2 个答案:

答案 0 :(得分:2)

如果您的XML开始标记包含

等属性
<article name="..." year="...." /> 

然后您应该使用开始标记和结束标记:

configuration.set("xmlinput.start", "<article");
configuration.set("xmlinput.end", "</article>");

请勿关闭第一篇文章标记,以便将该标记作为包含其他属性的标记。您不需要指定属性值。

答案 1 :(得分:0)

你必须像这样指定 -

Configuration conf = new Configuration();
conf.set("xmlinput.start", "<article>");