title: PHP/XML: Reading the position of a child node in the middle of the text of its parent
body: <p>I'm currently parsing an XML document of an instructional manual using PHP's <code>simplexml_load_file()</code> method, so I could create a digital version of the manual in PHP.</p>
  
  <p>At some points of the XML, there are nodes with text, and these texts have nodes inside them.</p>
  
  <p>Example:</p>
  
  <pre><code>&lt;BodyText dojo-id="XXXXXX"&gt;
      This is some text in the manual with
      &lt;HyperContainer dojo-id="XXXXXX"&gt;
          &lt;Hyper dojo-id="XXXXXX" MarkerType="Hypertext"&gt;
              www.somelink.com
          &lt;/Hyper&gt;
          some link
      &lt;/HyperContainer&gt;
      in between it.
  &lt;/BodyText&gt;
  </code></pre>
  
  <p>Now if I do <code>echo (string)$bodyText;</code> (assumming that <code>$bodyText</code> contains the instance of the <code>&lt;BodyText&gt;</code> node in the example shown) it gives me the text:</p>
  
  <pre><code>"This is some text in the manual with  in between it."
  </code></pre>
  
  <p>And I can easily access the <code>&lt;HyperContainer&gt;</code> node on PHP by <code>$bodyText-&gt;HyperContainer</code>, and I have no problem with that.</p>
  
  <p>I just need to know how can I get the position of the child node <code>&lt;HyperContainer&gt;</code> inside the text of its parent node <code>&lt;BodyText&gt;</code>, so I can insert the hyper link at that position on my markup/view code.</p>