예제 #1
0
             
          </td>
        </tr>
      </table>
      
      <?php 
// Check whether a file and a expression was given.
if (!empty($file) && !empty($expression)) {
    // Display a separator.
    echo "<br><hr><br>";
    // Include the <phpXML/> class.
    include "XMLBuilder.class.php";
    // Now create a new object for accessing the XML file.
    $xml = new XMLBuilder($file);
    // Evaluate the XPath expression.
    $results = $xml->evaluate($expression, $context);
    // Now check what action to perform.
    if ($action == "remove") {
        // Run through all nodes that were found.
        foreach ($results as $result) {
            // Remove the node.
            $xml->remove_node($result);
        }
        // Clear the results.
        $results = array();
    }
    // Now display the content of the XML file.
    echo "<pre>";
    echo $xml->get_file($results);
    echo "</pre>";
}
예제 #2
0
          <td><span class="small"><b>Surname</b></span></td>
          <td><span class="small"><b>Prename</b></span></td>
          <td><span class="small"><b>Party</b></span></td>
          <td><span class="small"><b>Position</b></span></td>
        </tr>
        
        <?php 
// Include the <phpXML/> class.
include "XMLBuilder.class.php";
// Create an XML object for the XML file.
$xml = new XMLBuilder("government.xml");
// Check whether a search term was given.
if (!empty($term)) {
    // Only select those persons, in whose name or position
    // the search string is present.
    $government = $xml->evaluate("//person/*[contains(., {$term})]/..");
} else {
    // Select all members of the government.
    $government = $xml->evaluate("//person");
}
// Run through all members of the government.
foreach ($government as $person) {
    // Retrieve information about the person.
    $surname = $xml->get_content($person . "/surname[1]");
    $prename = $xml->get_content($person . "/prename[1]");
    $party = $xml->get_content($person . "/party[1]");
    $position = $xml->get_content($person . "/position[1]");
    // Display the information.
    ?>
                
                <tr>