You must select the text from the html code. For example, given:

<div>first</div><div>second</div><br /><div> third</div>. 

Need to get:

first second third

I tried using jQuery.text() , but I get:

firstsecond third

What is not very good.

So how to do it by means of .NET , using, perhaps, third-party libraries? And preferably as productively as possible.

    2 answers 2

    Here are third-party libraries

    Html Agility Pack

    Html Agility Pack - convenient .NET HTML parser

      If you already used jQuery.text () then why do you want to use .NET now, and not rewrite the code to the correct one? Example:

       var txt = [] // массив в котором весь текст //собираем текст $('div').each(function(){ txt.push( $(this).text()) //заполняем массив }) //или так $('div').text(function(index,text){ txt.push( text ) }) console.log ( txt.join(' ') ) //делаем с ним все что вздумается 

      UPD. The answer was given with reference to the question. $ ('div') - can be replaced with any interesting construction:

      $ ('*') will take all the elements of the page.

      $ ('# id *') - will take all the elements inside the block with id = 'id'

      I think this part will not be difficult to correct for specific needs :)

      • and what if the text is: <h4> first </ h4> second? I meant ANY code HTML - megacoder
      • replace $ ('div') with the desired construction :) - iKuzko
      • in general, the html content is not known, the method should be universal - megacoder