2016-01-01 07:42:52 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class ParseXML {
|
2016-02-11 12:51:12 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function __construct() {
|
2016-02-11 12:51:12 -05:00
|
|
|
return true;
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
2016-02-11 12:51:12 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function GetElement($InputString, $ElementName) {
|
|
|
|
if (strpos($InputString, "<".$ElementName.">") === false) return false;
|
|
|
|
if (strpos($InputString, "</".$ElementName.">") === false) return false;
|
2016-02-11 12:51:12 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
$Element = substr($InputString, strpos($InputString, "<".$ElementName.">")+strlen($ElementName)+2, strpos($InputString, "</".$ElementName.">")-strpos($InputString, "<".$ElementName.">")-strlen($ElementName)-2);
|
|
|
|
return $Element;
|
2016-02-11 12:51:12 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
2016-02-11 12:51:12 -05:00
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
public function GetAllElements($InputString, $ElementName) {
|
|
|
|
$Elements = array();
|
|
|
|
while (strpos($InputString, $ElementName) !== false) {
|
|
|
|
$Elements[] = $this->GetElement($InputString, $ElementName);
|
2016-02-11 12:51:12 -05:00
|
|
|
$InputString = substr($InputString, strpos($InputString, "</".$ElementName.">")+strlen($ElementName)+3, strlen($InputString));
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
|
|
|
return $Elements;
|
|
|
|
}
|
2016-02-11 12:51:12 -05:00
|
|
|
|
|
|
|
|
2016-01-01 07:42:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-11 12:51:12 -05:00
|
|
|
?>
|