PHP getDocNamespaces() ফাংশন
Definition and Usage
The getDocNamespaces() function returns the namespaces declared in the XML document from the SimpleXMLElement object.
If successful, this function returns an array containing namespace names (with associated URLs). If failed, it returns false.
Syntax
class SimpleXMLElement { string getDocNamespaces();recursive) }
Parameter | Description |
---|---|
recursive | Optional. Specify whether to return all namespaces in the parent-child nodes. The default is false. |
Example
XML File:
<?xml version="1.0" encoding="ISO-8859-1"?> <note xmlns:b="http://www.codew3c.com/example/"></note> <to>George</to> <from>John</from> <heading>Reminder</heading> <b:body>Don't forget the meeting!</b:body> </note>
PHP Code:
<?php if (file_exists('test.xml')) { $xml = simplexml_load_file('test.xml'); } print_r();$xml->getDocNamespaces();); ?>
Output like:
Array ( [b] => http://www.codew3c.com/example/ )