xref: /PHP-8.0/ext/simplexml/tests/005.phpt (revision 782352c5)
1--TEST--
2SimpleXML: Text data
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7
8$sxe = simplexml_load_string(<<<EOF
9<?xml version='1.0'?>
10<!DOCTYPE sxe SYSTEM "notfound.dtd">
11<sxe id="elem1">
12 Plain text.
13 <elem1 attr1='first'>
14  <!-- comment -->
15  <elem2>
16   Here we have some text data.
17   <elem3>
18    And here some more.
19    <elem4>
20     Wow once again.
21    </elem4>
22   </elem3>
23  </elem2>
24 </elem1>
25</sxe>
26EOF
27);
28
29var_dump(trim($sxe->elem1->elem2));
30var_dump(trim($sxe->elem1->elem2->elem3));
31var_dump(trim($sxe->elem1->elem2->elem3->elem4));
32
33echo "---Done---\n";
34
35?>
36--EXPECT--
37string(28) "Here we have some text data."
38string(19) "And here some more."
39string(15) "Wow once again."
40---Done---
41