0

I have the following code, with which I select certain <text> elements from an xml file:

$xml = new DOMDocument();
$xml->load("quotes.xml");
$xpath = new DOMXpath($xml);
$search_results = $xpath->query("/quotes/quote/text[contains(.,'foo')]");

Now, the <text> elements that I am selecting contain mixed content, like so:

<text>Some text with <i>italics</i>, <link>links</link>, and <i><link>italicized links</link></i>.</text>

I would like to retrieve the entire mixed content, i.e. Some text with <i>italics</i>, <link>links</link>, and <i><link>italicized links</link></i>. How can this be done with DOM?

Thanks in advance for your help!

Wolfhart
  • 37
  • 6
  • 1
    Although the linked duplicate talks about inner _HTML_, the same approaches should work for getting inner _XML_. – IMSoP Feb 22 '22 at 21:22

0 Answers0