我现在需要DOM调用的是xml文档,而不是路径怎么写啊?
$doc = new DOMDocument; //xml开始解析
$doc->load("<?xml version="1.0" encoding='ISO-8859-1'?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>");我需要的是这样的效果,该怎么弄啊?

解决方案 »

  1.   

    $doc = new DOMDocument;$doc.load("文件名");
      

  2.   

    我就是需要解析xml字符才问这个问题的啊,请高手指点啊
      

  3.   

    把xml赋给某变量
    比如$xmlStr = '<?xml version="1.0" encoding='ISO-8859-1'?>
    <note>
    <to>George </to>
    <from>John </from>
    <heading>Reminder </heading>
    <body>Don't forget the meeting! </body>
    </note>';
    $doc->loadXML( $xmlStr );就可以了~loadXML()是载入  字符串;
    而load()是载入文件