I have a pretty big XML file structured with the TEI specification and I've been charged with the responsibility of basically migrating the XML into a Drupal installation but in order to do this, I need to extract only specific elements of the XML and simultaneously output these elements into a subsequent XML file for eventual use within Drupal.
Drupal aside for a second, the basic XML structure is as follows:
<div1 tyle="section" n="1" org="uniform" sample="complete">
With that structure above, how could I extract (parse?) for only head and the paragraphs inside the div1 elements and put this all into another XML file?
I tried to parse for what I wanted using the following...
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
So any help from you guys is appreciated as always. How can I parse for only certain elements and save the output as a straight up XML file?
You can have a look at SimpleXML since you know PHP.
To get the head element you would do something like this:
At this point you can save everything to a text file with PHP functions like fwrite