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? Quote 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? Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.