You are here

function XMLSchema::parseString in Salesforce Suite 5

Same name in this branch
  1. 5 includes/nusoap.php \XMLSchema::parseString()
  2. 5 includes/nusoap.orig.php \XMLSchema::parseString()
Same name and namespace in other branches
  1. 5.2 includes/nusoap.php \XMLSchema::parseString()
  2. 5.2 includes/nusoap.orig.php \XMLSchema::parseString()

* parse an XML string * *

Parameters

string $xml path or URL:

string $type, (schema|xml): * @access private

2 calls to XMLSchema::parseString()
XMLSchema::parseFile in includes/nusoap.php
parse an XML file
XMLSchema::parseFile in includes/nusoap.orig.php
parse an XML file

File

includes/nusoap.orig.php, line 1096

Class

XMLSchema
parses an XML Schema, allows access to it's data, other utility methods no validation... yet. very experimental and limited. As is discussed on XML-DEV, I'm one of the people that just doesn't have time to read the spec(s) thoroughly,…

Code

function parseString($xml, $type) {

  // parse xml string
  if ($xml != "") {

    // Create an XML parser.
    $this->parser = xml_parser_create();

    // Set the options for parsing the XML data.
    xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);

    // Set the object for the parser.
    xml_set_object($this->parser, $this);

    // Set the element handlers for the parser.
    if ($type == "schema") {
      xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement');
      xml_set_character_data_handler($this->parser, 'schemaCharacterData');
    }
    elseif ($type == "xml") {
      xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement');
      xml_set_character_data_handler($this->parser, 'xmlCharacterData');
    }

    // Parse the XML file.
    if (!xml_parse($this->parser, $xml, true)) {

      // Display an error message.
      $errstr = sprintf('XML error parsing XML schema on line %d: %s', xml_get_current_line_number($this->parser), xml_error_string(xml_get_error_code($this->parser)));
      $this
        ->debug($errstr);
      $this
        ->debug("XML payload:\n" . $xml);
      $this
        ->setError($errstr);
    }
    xml_parser_free($this->parser);
  }
  else {
    $this
      ->debug('no xml passed to parseString()!!');
    $this
      ->setError('no xml passed to parseString()!!');
  }
}