ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SimpleSAML\XML\Parser Class Reference
+ Collaboration diagram for SimpleSAML\XML\Parser:

Public Member Functions

 __construct ($xml)
 
 getValueDefault ($xpath, $defvalue)
 
 getValue ($xpath, $required=false)
 
 getValueAlternatives (array $xpath, $required=false)
 

Static Public Member Functions

static fromSimpleXMLElement (\SimpleXMLElement $element)
 

Data Fields

 $simplexml = null
 

Detailed Description

Definition at line 12 of file Parser.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML\XML\Parser::__construct (   $xml)

Definition at line 16 of file Parser.php.

References $xml.

17  {
18  ;
19  $this->simplexml = new \SimpleXMLElement($xml);
20  $this->simplexml->registerXPathNamespace('saml2', 'urn:oasis:names:tc:SAML:2.0:assertion');
21  $this->simplexml->registerXPathNamespace('saml2meta', 'urn:oasis:names:tc:SAML:2.0:metadata');
22  $this->simplexml->registerXPathNamespace('ds', 'http://www.w3.org/2000/09/xmldsig#');
23  }

Member Function Documentation

◆ fromSimpleXMLElement()

static SimpleSAML\XML\Parser::fromSimpleXMLElement ( \SimpleXMLElement  $element)
static

Definition at line 25 of file Parser.php.

References $parser.

26  {
27 
28  // Traverse all existing namespaces in element
29  $namespaces = $element->getNamespaces();
30  foreach ($namespaces as $prefix => $ns) {
31  $element[(($prefix === '') ? 'xmlns' : 'xmlns:' . $prefix)] = $ns;
32  }
33 
34  /* Create a new parser with the xml document where the namespace definitions
35  * are added.
36  */
37  $parser = new Parser($element->asXML());
38  return $parser;
39  }
$parser
Definition: BPMN2Parser.php:23

◆ getValue()

SimpleSAML\XML\Parser::getValue (   $xpath,
  $required = false 
)

Definition at line 50 of file Parser.php.

References $result.

Referenced by SimpleSAML\XML\Parser\getValueAlternatives(), and SimpleSAML\XML\Parser\getValueDefault().

51  {
52  $result = $this->simplexml->xpath($xpath);
53  if (!is_array($result) || empty($result)) {
54  if ($required) {
55  throw new \Exception('Could not get value from XML document using the following XPath expression: ' . $xpath);
56  } else {
57  return null;
58  }
59  }
60  return (string) $result[0];
61  }
$result
+ Here is the caller graph for this function:

◆ getValueAlternatives()

SimpleSAML\XML\Parser::getValueAlternatives ( array  $xpath,
  $required = false 
)

Definition at line 63 of file Parser.php.

References $x, and SimpleSAML\XML\Parser\getValue().

64  {
65  foreach ($xpath as $x) {
66  $seek = $this->getValue($x);
67  if ($seek) {
68  return $seek;
69  }
70  }
71  if ($required) {
72  throw new \Exception('Could not get value from XML document using multiple alternative XPath expressions.');
73  } else {
74  return null;
75  }
76  }
getValue($xpath, $required=false)
Definition: Parser.php:50
$x
Definition: complexTest.php:9
+ Here is the call graph for this function:

◆ getValueDefault()

SimpleSAML\XML\Parser::getValueDefault (   $xpath,
  $defvalue 
)

Definition at line 41 of file Parser.php.

References SimpleSAML\XML\Parser\getValue().

42  {
43  try {
44  return $this->getValue($xpath, true);
45  } catch (\Exception $e) {
46  return $defvalue;
47  }
48  }
getValue($xpath, $required=false)
Definition: Parser.php:50
+ Here is the call graph for this function:

Field Documentation

◆ $simplexml

SimpleSAML\XML\Parser::$simplexml = null

Definition at line 14 of file Parser.php.


The documentation for this class was generated from the following file: