New feature! Upgrade and increase expert visibility of your issues with Priority Questions.
/*And here's the code I'm trying to use to edit specific content nodes*/
<pages> <page> <contents>A bunch of text here </contents> </page> <page> <contents>A bunch of text here </contents> </page> <page> <contents>A bunch of text here </contents> </page> </pages>
So I'm not sure if my overall approach is wrong, or if I just need to modify the string variable make it an instance of DOMNode. Please Help! Thank you!
$data = new DOMDocument('1.0', 'utf-8'); $data->formatOutput = true; $data->preserveWhiteSpace = true; $data->load('../data.xml'); //load elements $page = $data->getElementsByTagName('page')->item(0); $contents = $page->getElementsByTagname('contents')->item(0); $contents = $string; //This is a string variable $page->replaceChild($contents, $contents); //This is the line that produces the error
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.