2012-04-19 60 views
1

我需要提取它提供XML如下一个HTTP Web服务信息的属性值:Solr的我怎样才能从XML使用dataimportHandler

<results> 
<parametros> 
    <param name="mode">xml</param> 
</parametros> 
<estacions> 
    <estacio id="72400" nom="Aeroport"/> 
    <estacio id="79600" nom="Arenys de Mar"/> 
    <estacio id="79404" nom="Badalona"/> 
    ... 
</estacions> 
</results> 

我怎样才能获得ttribute值?例如id和nom属性? 这里是我的数据配置文件,但我不明白如何实现这种情况。

<dataConfig> 
    <dataSource type="HttpDataSource" /> 
    <document> 
      <entity name="slashdot" 
        pk="link" 
        url=http://_host_/xmlservice/" 
        processor="XPathEntityProcessor" 
        forEach="/estacions" 
        transformer="DateFormatTransformer"> 
        <field column="idestacio"  xpath="/estacio.id" commonField="true" /> 
        <field column="nomestacio"  xpath="/estacio.nom" commonField="true" />       
      </entity> 
    </document> 
</dataConfig> 

回答

0

请参阅here如何使用JavaScript转换器来操纵使用XPath提取的值。

+0

而且,这家伙正在做类似的事情有先进的XPath的用法:HTTP:// grokbase。 COM /吨/ lucene的/ solr的用户/ 114szp8xhj /如何对串连两节点-的-XML与 - xpathentityprocessor – 2012-04-19 14:15:14