ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

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 }
$xml
Definition: metadata.php:240

References $xml.

Member Function Documentation

◆ fromSimpleXMLElement()

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

Definition at line 25 of file Parser.php.

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

References $parser.

◆ getValue()

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

Definition at line 50 of file Parser.php.

51 {
52 $result = $this->simplexml->xpath($xpath);
53 if (! $result or !is_array($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

References $result.

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

+ 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.

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: example_009.php:98

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

+ Here is the call graph for this function:

◆ getValueDefault()

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

Definition at line 41 of file Parser.php.

42 {
43 try {
44 return $this->getValue($xpath, true);
45 } catch (\Exception $e) {
46 return $defvalue;
47 }
48 }

References SimpleSAML\XML\Parser\getValue().

+ 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: