我有一个具有这种结构的 XML 文件(虽然不完全是一棵树)
<posthistory>
<row Id="1" PostHistoryTypeId="2" PostId="1"
RevisionGUID="689cb04a-8d2a-4fcb-b125-bce8b7012b88"
CreationDate="2015-01-27T20:09:32.720" UserId="4" Text="I just got a
pound of microroasted, local coffee and am curious what the optimal
way to store it is (what temperature, humidity, etc)" />
我正在使用 apache pig 使用此代码仅提取“文本”部分
grunt> A = load 'hdfs:///parsingdemo/PostHistory.xml' using
org.apache.pig.piggybank.storage.XMLLoader('posthistory') as(x:chararray);
grunt> result = foreach A generate XPath(x, 'posthistory/Text');
这返回“()”(空)
在检查 XML 文件后,我了解到我的 XML 文件应该采用以下格式:
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
但是我的 XML 数据文件(实际上是 stackoverflow 数据转储)不是这种格式。有没有办法可以强加树结构?我的猪查询有什么问题?