Search based on count of particular word

Tuesday, 21 May 2013 · 2 messages
JB
John Best21 May 2013 14:11 #
Hi there Below is a sample XML file. *******************************
<Docs>
<Doc>
  <Name>Doc 1</Name>
  <Info>Hurray</Info>
</Doc>
<Doc>
  <Name>Doc 2</Name>
  <Info>Brinjal is king of vegetables.</Info>
  </Doc>
<Doc>
  <Name>Doc 3</Name>
  <Info>Alexandar was a great king. His desire was to conquer the world and
rule the world as a king.</Info>
</Doc>
<Doc>
  <Name>Doc 4</Name>
  <Info>I love cherries.</Info>
</Doc>
<Doc>
  <Name>Doc 5</Name>
  <Info>Mango is king of fruits. Alphonso is king of mangoes. So Alphonso
is king's king.</Info>
</Doc>
</Docs>
************************ I want to search the <Info> tag for the word "king" and return the <Name> as output. I know this is simple... :) But the *order of the <Name> should be in order of the word searched (here it will be king) ie the most numbers will come first. * *Doc 5 (3 times king) * *Doc 3 (2 times king) * *Doc 2 (1 time king) * * *
-- Have a nice day JBest
CG
Christian Grün21 May 2013 14:16 #
Hi John, as your question could be of general interest for XQuery users and developers, I recommend you to rather post it to either talk at x-query.com or Stackoverflow. Best, Christian
Quoted text · John Best · 58 lines
On Tue, May 21, 2013 at 2:11 PM, John Best <johnbest5673 at gmail.com> wrote: > Hi there > > Below is a sample XML file. > > ******************************* > > <Docs> > <Doc> > <Name>Doc 1</Name> > <Info>Hurray</Info> > </Doc> > <Doc> > <Name>Doc 2</Name> > <Info>Brinjal is king of vegetables.</Info> > </Doc> > <Doc> > <Name>Doc 3</Name> > <Info>Alexandar was a great king. His desire was to conquer the world and > rule the world as a king.</Info> > </Doc> > <Doc> > <Name>Doc 4</Name> > <Info>I love cherries.</Info> > </Doc> > <Doc> > <Name>Doc 5</Name> > <Info>Mango is king of fruits. Alphonso is king of mangoes. So Alphonso is > king's king.</Info> > </Doc> > </Docs> > > ************************ > > I want to search the <Info> tag for the word "king" and return the <Name> as > output. I know this is simple... :) > > But the order of the <Name> should be in order of the word searched (here it > will be king) ie the most numbers will come first. > > Doc 5 (3 times king) > Doc 3 (2 times king) > Doc 2 (1 time king) > > > > > -- > Have a nice day > JBest > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >

⚡Generated with XQuery