TheJoey Posted May 12, 2010 Share Posted May 12, 2010 <?php $xmlDoc = new DOMDocument(); $xmlDoc->load("abc.xml"); // We need to validate our document before refering to the id $xmldoc->validateOnParse = true; function $id { } $xmldoc->getElementById('$id')->tagName . "\n"; print $xmlDoc->saveXML(); ?> <books> <book> <author>Jack Herrington</author> <title>PHP Hacks</title> <publisher>O'Reilly</publisher> </book> </books> im new to this sort of this but what im trying to do is make $id user inputted so if they wanted title it would file title from this file, im not sure how to go about writing a function for that Quote Link to comment https://forums.phpfreaks.com/topic/201499-php-dom/ Share on other sites More sharing options...
Adam Posted May 12, 2010 Share Posted May 12, 2010 If I understand you right, you may have better luck using getElementsByTagName() -- since I can't see any IDs used within your XML. Quote Link to comment https://forums.phpfreaks.com/topic/201499-php-dom/#findComment-1057174 Share on other sites More sharing options...
TheJoey Posted May 13, 2010 Author Share Posted May 13, 2010 No i want to right the function for $id, if thats possible? where it will take the "search string" from the user php parse Quote Link to comment https://forums.phpfreaks.com/topic/201499-php-dom/#findComment-1057539 Share on other sites More sharing options...
TheJoey Posted May 13, 2010 Author Share Posted May 13, 2010 Ok, my mistake there is a user field, how do i make it so that the userfield becomes the search string, do i need a function write? Quote Link to comment https://forums.phpfreaks.com/topic/201499-php-dom/#findComment-1057716 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.