title: How to extract text including inline elements and the xpath to that element of the HTML page in Python
body: <p>I am working on a Django project where I need to extract all the text-containing elements and the xPath to that element. e.g:</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;
          The Demo page
      &lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div&gt;
          &lt;section&gt;
              &lt;h1&gt; Hello world
              &lt;/h1&gt;
          &lt;/section&gt;
          &lt;div&gt;
              &lt;p&gt;
                  Hope you all are doing well,
              &lt;/p&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;p&gt;
                  &lt;span&gt;This is the&lt;/span&gt; example HTML
              &lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The output should be something like:</p>
  <pre><code>/head/title: The Demo Page
  /body/div/section/h1: Hello world!
  /body/div/div[1]/p: Hope you all are doing well,
  /body/div/div[2]/p: &lt;span&gt;This is the&lt;/span&gt; example HTML
  </code></pre>