@@ 16-29 (lines=14) @@ | ||
13 | $this->domXpath = new \DOMXPath($domDocument); |
|
14 | } |
|
15 | ||
16 | public static function fromFile(string $filePath): self |
|
17 | { |
|
18 | $domDocument = new \DOMDocument(); |
|
19 | ||
20 | try { |
|
21 | if (false === file_exists($filePath) || false === $domDocument->load($filePath)) { |
|
22 | throw new \RuntimeException(sprintf('Could not load xml file [%s].', $filePath)); |
|
23 | } |
|
24 | } catch (\Exception $e) { |
|
25 | throw new \RuntimeException($e->getMessage()); |
|
26 | } |
|
27 | ||
28 | return new self($domDocument); |
|
29 | } |
|
30 | ||
31 | public static function fromString(string $xmlStr): self |
|
32 | { |
|
@@ 31-44 (lines=14) @@ | ||
28 | return new self($domDocument); |
|
29 | } |
|
30 | ||
31 | public static function fromString(string $xmlStr): self |
|
32 | { |
|
33 | $domDocument = new \DOMDocument(); |
|
34 | ||
35 | try { |
|
36 | if (false === $domDocument->loadXML($xmlStr)) { |
|
37 | throw new \RuntimeException(sprintf('Could not load XML from string [%s]', $xmlStr)); |
|
38 | } |
|
39 | } catch (\Exception $e) { |
|
40 | throw new \RuntimeException($e->getMessage()); |
|
41 | } |
|
42 | ||
43 | return new self($domDocument); |
|
44 | } |
|
45 | ||
46 | public function getList(string $xpath): \Generator |
|
47 | { |