nottingham Posted August 26, 2011 Share Posted August 26, 2011 <?php $dom = new DOMDocument(); $dom->loadHTMLFile('http://en.wikipedia.org/wiki/Liverpool_F.C.'); $domxpath = new DOMXPath($dom); foreach ($domxpath->query('//span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"]') as $a) {echo " <p>$a->textContent</p> "; }; ?> Hello, how can I parse an XML that includes all of the $a->textContent with a tag like <player></player>? Quote Link to comment https://forums.phpfreaks.com/topic/245776-php-xml-parser-question/ Share on other sites More sharing options...
silkfire Posted August 26, 2011 Share Posted August 26, 2011 Your description is a bit vague, do you want to replace <p>$a->textContent</p> with <player>$a->textContent</player> (probably not) ? Quote Link to comment https://forums.phpfreaks.com/topic/245776-php-xml-parser-question/#findComment-1262437 Share on other sites More sharing options...
nottingham Posted August 27, 2011 Author Share Posted August 27, 2011 I want to all players to be in a different <player> tag. Quote Link to comment https://forums.phpfreaks.com/topic/245776-php-xml-parser-question/#findComment-1262472 Share on other sites More sharing options...
silkfire Posted August 27, 2011 Share Posted August 27, 2011 Just replace <p> with <player>? Quote Link to comment https://forums.phpfreaks.com/topic/245776-php-xml-parser-question/#findComment-1262560 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.