Search

Hi,

While developing extensions, I seem to miss certain functionality in the XMLElement-class. I think of functions such as:

  • removeChild
  • setChildren
  • replaceChild
  • appendChildAt (to append a child at a certain position instead of default on the end

What also would be nice if there was some kind of search in the XMLElement class (perhaps with XPath?) returning the correct element.

I thought this would make extension development somewhat easier. Are there any thoughts on this? Or does it require some special scripting? I could imagine having a XMLElement-class and a XMLElementHelper-class or something to provide some extra tools for working with XMLElements.

Or does it require some special scripting?

Very much so. In Symphony 2 the XMLElement class isn’t actually XML at all, it stores the XML representation as objects (arrays). When you call generate() on the object is iterates an creates an XML string. To this end, it’s not really possible to implement an XPath lookup on the object itself.

If you’re finding using XMLElement difficult, then you can sometimes use DomDocument (or simplexml) instead. But it depends where you’re using it.

Symphony 3 solves this by using DomDocument (the native PHP object) which you can run XPath against. It has the benefit of being much faster and a much smaller memory footprint too.

Symphony 3 solves this by using DomDocument

Allright! Looking forward to Symphony 3! So if I understand correctly, in Symphony 3 the XMLElement class will be no longer used?

Say hi to SymphonyDomElement!

Is there any scope of DomDocument appearing in 2.4?

Have the same bottleneck as Giel while playing with Extension to override a returned $wrapper element in displayPublishPanel.

To be able to replace element with a simple function would be ace.

This will be out of scope for 2.4, but perhaps we can try and get it in for 2.5

Ok cool, Managed to use removeChildAt to do what I needed now anyways :)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details