I have a XML file that I want to delete the first and last section from (I am going to merge several XML files so I have to remove both the begining and the end of these files).
Do anyone have a clue? The file is read into a variable and I want to remove everything before and including the word “”
Here a sample with two functionalities: extract the “” tag, and delete everything, except for the contents of the “” tag.
set myXML to "<roastbeef>
<soap>Madrid but I like apples</soap>
</roastbeef>"
--> keep only the "<soap>" tag
set soapStart to (offset of "<soap>" in myXML)
set soapEnd to (offset of "</soap>" in myXML) + 6 --> adjust length
set soapTag to text soapStart thru soapEnd of myXML
--> keep all within the "<roastbeef>" tag
set init to (offset of "<roastbeef>" in myXML) + 11
set endit to (offset of "</roastbeef>" in myXML) - 1
set allWithinRoastbeef to text init thru endit of myXML
{soapTag, allWithinRoastbeef}