Phasma Felis Posted August 8, 2007 Share Posted August 8, 2007 I want to find all elements named "field" in an XML doc and assign a new value to each one. I'd tried something like this: foreach ($xml->xpath('//field') as &$field) $field = $value; But that doesn't work, because (I think) XPath returns a temporary array, not a reference to an actual element. ("PHP Fatal error: Cannot create references to elements of a temporary array expression") Is there a way to assign values to elements located with XPath, or do I just have to iterate over the whole document? Link to comment https://forums.phpfreaks.com/topic/63972-simplexml-assigning-values-to-elements-found-with-xpath/ Share on other sites More sharing options...
Phasma Felis Posted August 9, 2007 Author Share Posted August 9, 2007 Bump? Link to comment https://forums.phpfreaks.com/topic/63972-simplexml-assigning-values-to-elements-found-with-xpath/#findComment-319704 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.