我对PHP不是很了解,请大家帮忙

解决方案 »

  1.   

    似乎你在用php解吸xml的时候 在读到<title>和</title>中间的时候可以修改
    应该并不难
      

  2.   

    你要用php修改xml然后保存是么?
    如果是那也可以按我上面说的那样
    先read()然后改就可以了!
      

  3.   

    用php5.0的 DOMDocument来处理。
      

  4.   

    Here is a simple example for replacing a node:Let's define our XML like so:<?php
    $xml = <<<XML
    <?xml version="1.0"?>
    <root>
      <parent>
         <child>bar</child>
         <child>foo</child>
      </parent>
    </root>
    XML;?>If we wanted to replace the entire <parent> node, we could do something like this:<?php
    // Create a new document fragment to hold the new <parent> node
    $parent = new DomDocument;
    $parent_node = $parent ->createElement('parent');// Add some children
    $parent_node->appendChild($parent->createElement('child', 'somevalue'));
    $parent_node->appendChild($parent->createElement('child', 'anothervalue'));// Add the keywordset into the new document
    // The $parent variable now holds the new node as a document fragment
    $parent->appendChild($parent_node);
    ?>Next, we need to locate the old node:<?php
    // Load the XML
    $dom = new DomDocument;
    $dom->loadXML($xml);// Locate the old parent node
    $xpath = new DOMXpath($dom);
    $nodelist = $xpath->query('/root/parent');
    $oldnode = $nodelist->item(0);
    ?>We then import and replace the new node:<?php
    // Load the $parent document fragment into the current document
    $newnode = $dom->importNode($parent->documentElement, true);// Replace
    $oldnode->parentNode->replaceChild($newnode, $oldnode);// Display
    echo $dom->saveXML();
    ?>Our new node is successfully imported:<?xml version="1.0"?>
    <root>
    <parent><child>somevalue</child><child>anothervalue</child></parent>
    </root> 
      

  5.   

    把 echo  $dom-  >saveXML(); 改为 dom-  >save('xml文件名'); 就可以保存文件了