I have an XML file with the following Document Type Declaration:
“`
<!DOCTYPE Credits SYSTEM “http://www.mrinitialman.com/././DTD-XSD/./mrinitialman.dtd” [
<!ENTITY fa “http://www.furaffinity.net/user/”>
<!ENTITY da “.deviantart.com/”>
<!ENTITY weasyl “https://www.weasyl.com/~”>
<!ENTITY tweet “https://twitter.com/”>
<!ENTITY wiki-en “https://en.wikipedia.org/wiki/”>
<!ENTITY hymnarybio “https://hymnary.org/person/”>
<!ENTITY kerkliedwiki “https://kerkliedwiki.nl/”>
<!ENTITY wiki-nl “https://nl.wikipedia.org/wiki/”>
]>
My PHP is simply ignoring all entity references; for example instead of seeing the attribute `url=”&wiki-en;Anne_Steele”
So, I’d like to try a workaround in which I have PHP read all the Entities and get their text values, and go from there.
The problem is, I’m not getting anything.
For example: should I try the following:
“`PHP
$entityarray=array();
$xml = new DOMDocument();
$xml->LoadXML(xmlfile.xml);
$entities = $xml->doctype->entities;
for($entity_num = 0; $entity_num < $entities->length; $entity_num++){
$entity = $entities->item($entity_num);
$entity_name = $entity->nodeName;
$entityarray[$entity_name] = $xml->SaveXML($entity);
}
I get an associated array of the _whole“`<!ENTITY wiki-en “https://en.wikipedia.org/wiki/”>
If, however, I try this:
“`PHP
for($entity_num = 0; $entity_num < $entities->length; $entity_num++){
$entity = $entities->item($entity_num);
$entity_name = $entity->nodeName;
$entityarray[$entity_name] = $entity->nodeValue;
}
or
“`PHP
for($entity_num = 0; $entity_num < $entities->length; $entity_num++){
$entity = $entities->item($entity_num);
$entity_name = $entity->nodeName;
$entityarray[$entity_name] = $entity->textContent;
}
I get an associated array of empty strings. Do I need to trim the entity code down to what I want? Is there something else I should do? Or am I just wasting my time struggling with Entity references?