Check out Scrivo

Do you want to try out Scrivo? Then here's a demo for you that does not just get your feet wet but lets you plunge right in.

Contact us

For more information, please contact us. We're happy to help you out!

Next Oct 28 Previous


For what do you use xml_set_object()?

A: To convert a PHP object to a DOM document.
B: To set multiple attributes on a DOM node at once.
C: To set an XPath query object that can be used for repetitive queries later.
D: To instruct the XML parser to use an object for its element handlers.


When you start using xml_parse() you'll quickly found out that you will need to store data in between open-data-close handlers. And that's calling for global variables. As we are professional programmers we don't like that a bit.

xml_set_object() allows for a neat way to define your handlers in a class and use an instance of that class to provide the callbacks for xml_parse(). This way you can store intermediate parsing data as private members of that class too. Even the parser itself can be a member of the class, see xml_set_object() for an example.

So answer D is the correct one, the other answers were just one Bourbon, one Scotch, one Beer.