I'm trying to parse an XML of a dtbook, which contains levels (1, 2 and 3) that later on contains p-tags. I'm doing this with PHP DOM. Link to XML
Inside som of these p-tags there are noteref-tags. I do get a hold of those, but it seems that the only results I'm able to get is either that the noteref appears before the p-tag, or after. I need some of the noterefs to appear inside the p-tag; or in other words, where they actually are supposed to be.
<p>Special education for the ..... <noteref class="endnote" idref="fn_5"
id="note5">5</noteref>. Interest ..... 19th century <noteref class="endnote"
idref="fn_6" id="note6">6</noteref>.</p>
This is the code I've got for the p-tag now. Before this, I'm looping through the dt-book to get tho the p-tag. That works fine.
if($level1->tagName == "p") {
echo "<p>".$level1->nodeValue;
$noterefs = $level1->childNodes;
foreach($noterefs as $noteref) {
if($noteref->nodeType == XML_ELEMENT_NODE) {
echo "<span><b>".$noteref->nodeValue."</b></span>";
}
}
echo "</p><br>";
}
These are the results I get:
Special education for the ..... 5. Interest ..... 19th century 6.56
56Special education for the ..... 5. Interest ..... 19th century 6.
I also want the p-tag to not display what's inside the noteref-tag. That should be done by the noteref-tag (only).
So, does anybody know what could possibly be done to fix these things? It feels like I've both googled and tried almost everything.