$root = new SimpleXMLElement("<".$key."/>");
self::fromArray($value, $root, $remove_header, $namespaces, false);
} else {
$root = new SimpleXMLElement("<".$key."/>");
self::fromArray($value, $root, $remove_header, $namespaces, false);
} else {
} elseif (is_array($value)) {
$element = $xml->addChild($key, null, $namespace);
self::fromArray($value, $element, $remove_header, $namespaces, false);
} elseif (is_array($value)) {
$element = $xml->addChild($key, null, $namespace);
self::fromArray($value, $element, $remove_header, $namespaces, false);
public static function copy(&$source, &$target, $elementname)
{
if (count($source->children()) == 0) {
public static function copy(&$source, &$target, $elementname)
{
if (count($source->children()) == 0) {
} else {
$child = $target->addChild($elementname);
foreach ($source->children() as $childfield => $childentry) {
} else {
$child = $target->addChild($elementname);
foreach ($source->children() as $childfield => $childentry) {
- * @param object $doc XML root
- * @param string $element XML element name
- * @param string $value XML value
- * @param array $attributes array containing the attributes
+ * @param \DOMDocument $doc XML root
+ * @param string $element XML element name
+ * @param string $value XML value
+ * @param array $attributes array containing the attributes
- public static function createElement($doc, $element, $value = "", $attributes = [])
+ public static function createElement(\DOMDocument $doc, $element, $value = "", $attributes = [])
* @param object $parent parent object
* @param string $element XML element name
* @param string $value XML value
* @param array $attributes array containing the attributes
* @return void
*/
* @param object $parent parent object
* @param string $element XML element name
* @param string $value XML value
* @param array $attributes array containing the attributes
* @return void
*/
- public static function addElement($doc, $parent, $element, $value = "", $attributes = [])
+ public static function addElement(\DOMDocument $doc, $parent, $element, $value = "", $attributes = [])
{
$element = self::createElement($doc, $element, $value, $attributes);
$parent->appendChild($element);
{
$element = self::createElement($doc, $element, $value, $attributes);
$parent->appendChild($element);
* (namespaces, lowercase tags, get_attribute default changed, more...)
*
* Examples: $array = Xml::toArray(file_get_contents('feed.xml'));
* (namespaces, lowercase tags, get_attribute default changed, more...)
*
* Examples: $array = Xml::toArray(file_get_contents('feed.xml'));
- * $array = Xml::toArray(file_get_contents('feed.xml', true, 1, 'attribute'));
+ * $array = Xml::toArray(file_get_contents('feed.xml', true, 1, 'attribute'));
- * @param object $contents The XML text
- * @param boolean $namespaces True or false include namespace information
- * in the returned array as array elements.
- * @param integer $get_attributes 1 or 0. If this is 1 the function will get the attributes as well as the tag values -
- * this results in a different array structure in the return value.
- * @param string $priority Can be 'tag' or 'attribute'. This will change the way the resulting
- * array sturcture. For 'tag', the tags are given more importance.
+ * @param object $contents The XML text
+ * @param boolean $namespaces True or false include namespace information
+ * in the returned array as array elements.
+ * @param integer $get_attributes 1 or 0. If this is 1 the function will get the attributes as well as the tag values -
+ * this results in a different array structure in the return value.
+ * @param string $priority Can be 'tag' or 'attribute'. This will change the way the resulting
+ * array sturcture. For 'tag', the tags are given more importance.
*/
public static function toArray($contents, $namespaces = true, $get_attributes = 1, $priority = 'attribute')
{
*/
public static function toArray($contents, $namespaces = true, $get_attributes = 1, $priority = 'attribute')
{
- Logger::log('libxml: parse: ' . $err->code." at ".$err->line.":".$err->column." : ".$err->message, Logger::DATA);
+ Logger::info('libxml error', ['code' => $err->code, 'position' => $err->line . ":" . $err->column, 'message' => $err->message]);
{
$result = $xpath->evaluate($element, $context);
if (!is_object($result)) {
{
$result = $xpath->evaluate($element, $context);
if (!is_object($result)) {
{
$result = $xpath->query($element, $context);
if (!is_object($result)) {
{
$result = $xpath->query($element, $context);
if (!is_object($result)) {