0

I use org.apache.solr.client.solrj.util.ClientUtils to convert an SolrInputDocument into a XML string and send to a queue. Now I need to manipulate that xml in a consumer, Ideally I want to have the xml convert back to SolrInputDocument, So I can add/drop couple fields with its methods. Is there an easy way to achieve that? Or any suggestions?

simonxy
  • 317
  • 4
  • 11

2 Answers2

1

you can generally use something like xstream/marshall API for this...that said, the XML that is output from the ClientUtils.toXML() call doesn't work with this approach.

per this post..."this is best done programmatically"

Community
  • 1
  • 1
Ben ODay
  • 20,784
  • 9
  • 45
  • 68
  • I ended up going other way to get what I need. But the post you attached here is really interesting. will look at that later. thx – simonxy Nov 07 '12 at 00:39
0

The other way of doing this is to parse your xml then convert it to java class. You can use SaxParser for this. See this link.

XML parsing using SaxParser with complete code

ryacii
  • 527
  • 4
  • 11
  • I know I can always do that in SAX, I would expect that solrj has sort of nice interface to solve this problem, 'cause I really just need to make small changes there. – simonxy Nov 06 '12 at 01:07