使用simplexml_load_file()加载XML时出现警告

I have an XML file named po.xml:

<?xml version="1.0" encoding="utf-8"?>
    <DOCUMENT xmlns="po.xsd">
        <PO>
            <HEADER>
                <PO_CODE/>
                <PO_NAME/>
                <REFF_NO/>
            </HEADER>
            <DETAIL>
                <CONT>
                    <NO_CONT/>
                    <UK_CONT/>
                    <NO_SEGEL/>
                    <JNS_CONT/>
                    <ISO_CODE/>
                </CONT>
            <DETAIL>
        </PO>
    </DOCUMENT>

When I load the file using the following PHP script:

$XML = simplexml_load_file('po.xml');

I get these warnings:

Warning: simplexml_load_file(): po.xml:2: namespace warning : xmlns: URI po.xsd >is not absolute in C:\xampp\htdocs\inventory\po.php on line 3

Warning: simplexml_load_file(): in C:\xampp\htdocs\inventory\po.php on line 3

Warning: simplexml_load_file(): ^ in C:\xampp\htdocs\inventory\po.php on line >3');

I want to echo the XML structure of po.xml as a string.

this sample xml is invalid. try closing the <DETAIL> tag.

You have two errors in your xml

First, the xmlns="po.xsd" should use absolute path.

From the libxml webpage http://www.xmlsoft.org/namespaces.html:

The namespace value has to be an absolute URL, but the URL doesn't have to point to any existing resource on the Web.

This question have been discussed here: Error loading xml in php (not absolute)

if you remove or fix this part with something like xmlns="http://www.example.com/po.xsd" it should works.

And as mentioned by Jeff Pucket, your tag <DETAIL> should be closed

<DETAIL>
   <CONT>
   <NO_CONT/>
   ....
   </CONT>
</DETAIL>