[PHP] SimpleXML & libxml options (XInclude)
Hi there. I'm hoping someone can help me with what I think might be a slightly obscure problem. I'm trying to get the SimpleXML extension to read an XML file and process the XInclude statements within the XML file. The SimpleXML docs state that libxml options may be specified using the predefined constants that are available when PHP is compiled with libxml support (as it is when you use SimpleXML). http://uk2.php.net/manual/en/function.simplexml-element-construct.php So, looking at the libxml options, I see there is a predefined constant LIBXML_XINCLUDE which when specified should implement XInclude substitution. So my SimpleXML object I define as follows: $xml_file = './master.xml'; $xml = new SimpleXMLElement($xml_file, LIBXML_XINCLUDE, true); print_r($xml); Viewing the resulting datastructure shows me that it has not honoured the request to implement the XInclude directives. Does anyone know if a) I'm using the correct syntax for this, and b) have any experience of getting this working. My master.xml file looks like this: http://www.w3.org/2001/XInclude";> ssd sss xinclude - a.xml not found and then I have a.xml which looks like: test test more I'm running PHP 5.1.5 with libxml 2.6.20 on Fedora Core 4 linux. Cheers Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SimpleXML & libxml options (XInclude)
Rob wrote: Ben Roberts wrote: I'm trying to get the SimpleXML extension to read an XML file and process the XInclude statements within the XML file. The SimpleXML docs state that libxml options may be specified using the predefined constants that are available when PHP is compiled with libxml support (as it is when you use SimpleXML). http://uk2.php.net/manual/en/function.simplexml-element-construct.php LIBMLXML_XINLCUDE currently only works with XMLReader. You would need to import your doc to DOM and then processes the xinclude: $xml_file = './master.xml'; $xml = new SimpleXMLElement($xml_file, 0, true); $dom = dom_import_simplexml($xml); $dom->ownerDocument->xinclude(); print_r($xml); Rob Thanks Rob. That works. And it appears to work flawlessly if you subsequently convert it back to a SimpleXML object too: $xml = new SimpleXMLElement($xml_file, 0, true); $dom = dom_import_simplexml($xml); $dom->ownerDocument->xinclude(); $xml = simplexml_import_dom($dom); Dump($xml); I have to convert it back to the SimpleXML object as I have an existing application that relies on the SimpleXML structure. Is it likely that this will be supported directly by SimpleXML in future versions of PHP? Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SimpleXML & libxml options (XInclude)
Rob Richards wrote: No need to even do that. The document is the same document (zero copy which is why going back and forth is efficient), so when its changed by the xinclude call, it is reflected in $xml already. Only reason you would need to do conversions back and forth is if you need specific nodes that might have been added/changed by the other extension. Here you are using the same root element and dont have to worry about losing any child references you might already have, so its a wasted call. So really when you perform: $dom = dom_import_simplexml($xml); the $dom object is really created by taking a reference to the $xml object rather than copying it? i.e. (I know this isn't real code) $dom = dom_import_simplexml(& $xml); Is this correct? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SimpleXML & libxml options (XInclude)
> Rob Richards wrote: > Although I doubt someone use the code above, it is the smallest piece > of code I could write to demonstrate the possibility. Thanks Rob - that does demonstrate things nicely. Cheers for your help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Where is phpm
I'm trying to download the phpm command line PHP documentation widget - all sources I can find point me to http://eide.org/?epc=php but there's nothing available here. Does anyone know where I can find phpm please ? Thanks Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where is phpm
Ben Roberts wrote: I'm trying to download the phpm command line PHP documentation widget - all sources I can find point me to http://eide.org/?epc=php but there's nothing available here. Does anyone know where I can find phpm please ? Thanks Ben Any takers? Has anyone got a copy of phpm they can send to me instead? Does anybody know anything about phpm. I'm trying to get vim to lookup function references in the PHP manual. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show Filename using Wildcards
Rahul Sitaram Johari wrote: So I have to accomplish two things: 1. I have to eliminate the filepath from the result 2. I need to specify the variable that holds the phone number, (like $row[ŒPHONE¹]) instead of the actual phone number in the ³exec² command. Thanks!! Much Appreciated! To get the filename component without the path, just use the basename() function: $file = basename($path); Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where is phpm
Matt Carlson wrote: I don't know how much of it I have left. I know that I hacked it up quite a bit when I created an irc bot with the php reference manual. Unfortunately, there really isn't an easy way to get function information as such from inside of php, without parsing php's website. The phpdoc stuff wasn't very intuitive on how to parse it, and trying to search for "xml php documentation" didn't really help (wy too many results, mostly dealing with how to use xml in php). If you DO find the updated info, I would also love to get a copy, as my hacked up version seems to be quite old. Ah - there is someone out there who knows what I'm talking about! Brilliant. Yes, I've only come across phpm via Tobias Schlitt's PDV work for vim (see http://svn.toby.phpugdo.de/horde/chora/co.php?r=29&f=README.txt). I think the author of phpm is Håvard Eide (nucleuz) who runs http://eide.org/ and appears to have installed Wordpress on the domain last November and then not done anything with the site in the meantime. Unfortunately this appears to have broken then only link I can find to the download of phpm. If anyone has any further information about this it would be appreciated. Alternatively, if anyone has any suggestions about how to get PHP function lookups in vim using another method Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php