XML : Get XML namespace of root node

I receive xml like:

  <?xml version="1.0" encoding="UTF-8"?>  <?xml-stylesheet type="text/xsl" href="http://adress.pl/FeResourceServlet/localTemplate/template1/styl.xsl"?>  <wnio:Dokument   xmlns:adr="http://adress.pl/xml/schema/adress/2009/11/09/"   xmlns:ds="http://www.w3.org/2000/09/xmldsig#"   xmlns:ev="http://www.w3.org/2001/xml-events"   xmlns:inst="http://adress.pl/xml/schematy/instytucja/2009/11/16/"   xmlns:meta="http://adress.pl/xml/schematy/meta/2009/11/16/"   xmlns:oso="http://adress.pl/xml/schematy/osoba/2009/11/16/"   xmlns:str="http://adress.pl/xml/schematy/struktura/2009/11/16/"      xmlns:wnio="http://epuap.gov.pl/FeResourceServlet/localTemplate/ZgloszenieBudowy/"   xmlns:xf="http://www.w3.org/2002/xforms"   xmlns:xsd="http://www.w3.org/2001/XMLSchema"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"  xsi:schemaLocation="http://adress.pl/FeResourceServlet/localTemplate/template1/ http://epuap.gov.pl/FeResourceServlet/localTemplate/template1/schema.xsd">  ...    

My question is - How can I get a namespace of root? Above my root node is wnio:Dokument and I know that wnio is "namespace of root" and name of root is Dokument.

But name and namespace can be changed. Then I will have root node but I wouldn't know namespace and name of root.

I used so far: SimpleXMLElement::getNamespaces and SimpleXMLElement::getDocNamespaces. But I received every namespace but I don't know which is root.

It's possible in PHP to get these information?

No comments:

Post a Comment