PHP -zelfstudie

PHP HOME PHP-intro PHP-installatie PHP-syntaxis PHP-opmerkingen PHP-variabelen PHP-echo / afdrukken PHP-gegevenstypen PHP-strings PHP-nummers PHP-wiskunde PHP-constanten PHP-operators PHP Als...Anders...Anders PHP-switch PHP-loops PHP-functies PHP-arrays PHP Superglobals PHP RegEx

PHP- formulieren

PHP-formulierverwerking PHP-formuliervalidatie PHP-formulier vereist URL/e-mail van PHP-formulier PHP-formulier voltooid

PHP Geavanceerd

PHP-datum en tijd PHP opnemen PHP-bestandsverwerking PHP-bestand openen/lezen PHP-bestand maken/schrijven PHP-bestand uploaden PHP-cookies PHP-sessies PHP-filters PHP-filters geavanceerd PHP-callback-functies PHP JSON PHP-uitzonderingen

PHP OOP

PHP Wat is OOP PHP-klassen/objecten PHP-constructor PHP-vernietiger PHP-toegangsmodificaties PHP-overerving PHP-constanten PHP abstracte lessen PHP-interfaces PHP-kenmerken PHP statische methoden Statische eigenschappen van PHP PHP-naamruimten PHP-iterables

MySQL- database

MySQL-database MySQL Connect MySQL DB maken MySQL-tabel maken MySQL Gegevens invoegen MySQL Laatste ID ophalen MySQL Meerdere invoegen MySQL voorbereid MySQL Gegevens selecteren MySQL Waar MySQL Bestel op MySQL Gegevens verwijderen MySQL-updategegevens MySQL-limietgegevens

PHP XML

PHP XML-parsers PHP SimpleXML-parser PHP SimpleXML - Get PHP XML Expat PHP XML DOM

PHP - AJAX

Ajax-intro AJAX PHP AJAX-database AJAX XML Live zoeken in Ajax Ajax-peiling

PHP- voorbeelden

PHP-voorbeelden PHP-compiler PHP-quiz PHP-oefeningen PHP-certificaat

PHP- referentie

PHP-overzicht PHP-array PHP-agenda PHP-datum PHP-map PHP-fout PHP-uitzondering PHP-bestandssysteem PHP-filter PHP FTP PHP JSON PHP-sleutelwoorden PHP Libxml PHP-e-mail PHP-wiskunde PHP Diversen PHP MySQLi PHP-netwerk PHP-uitvoercontrole PHP RegEx PHP SimpleXML PHP-stream PHP-string Beheer van PHP-variabelen PHP XML-parser PHP-zip PHP-tijdzones

PHP getDocNamespaces() Functie

❮ PHP SimpleXML-referentie

Voorbeeld

Retourneer de naamruimten die zijn gedeclareerd in de hoofdmap van het XML-document:

<?php
$xml=<<<XML
<?xml version="1.0" standalone="yes"?>
<cars xmlns:c="http://w3schools.com/ns">
  <c:car id="1">Volvo</c:car>
  <c:car id="2">BMW</c:car>
  <c:car id="3">Saab</c:car>
</cars>
XML;

$sxe=new SimpleXMLElement($xml);
$ns=$sxe->getDocNamespaces();
print_r($ns);
?>

Definitie en gebruik

De functie getDocNamespaces() retourneert de naamruimten die in een XML-document zijn gedeclareerd.


Syntaxis

SimpleXMLElement::getDocNamespaces(recursive, from_root)

Parameterwaarden

Parameter Description
recursive Optional.  Specifies a Boolean value. If TRUE, all namespaces declared in document are returned. If FALSE, only namespaces declared in root node is returned. Default is FALSE
from_root Optional. Specifies a Boolean value. TRUE checks namespaces from the root of the XML document. FALSE checks namespaces under a child node. Default is TRUE


Technische details

Winstwaarde: Een reeks naamruimtenamen met de bijbehorende URI's
PHP-versie: 5.1.2+
PHP-wijzigingslogboek: PHP 5.4: De from_root parameter is toegevoegd

Meer voorbeelden

Voorbeeld

Retourneer alle naamruimten die in het XML-document zijn gedeclareerd:

<?php
$xml=<<<XML
<?xml version="1.0" standalone="yes"?>
<cars xmlns:c="http://w3schools.com/ns">
  <c:car id="1">Volvo</c:car>
  <c:car id="2">BMW</c:car>
  <c:car id="3" a:country="Sweden" xmlns:a="http://w3schools.com/country">Saab</c:car>
</cars>
XML;

$sxe=new SimpleXMLElement($xml);
$ns=$sxe->getDocNamespaces(TRUE);
var_dump($ns);
?>

❮ PHP SimpleXML-referentie