Ash3r Posted April 16, 2010 Share Posted April 16, 2010 I am trying to create a TeamWarfare.com plugin for a clan. I am new to PHP coding so please excuse me for my bad code... Here is the page that I am using to test my core framework of the plugin i am trying to create ... http://testing.a3designs.com Here is the XML entry... <ladder name="Battlefield: Bad Company 2 - NA 4v4 Squad Rush"> I want to pull the "Battlefield: Bad Company 2 - NA 4v4 Squad Rush" portion of the code. Here is the code I have been using to pull XML info for other fields... $name = $value->getElementsByTagName("name"); $names = $name->item(0)->nodeValue; i have tried using $ladder = and $name = and '$ladder name' = but i am stuck on this little tiny issue ... please someone help me ! Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 I can clearly say.. '$ladder name' = Will NOT work in anyway at all. What is $value? Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 16, 2010 Author Share Posted April 16, 2010 LOL ... i see that... what do you mean by $value ... again I am new so please be gentle ! The "value" i want to pull is the Battlefield: Bad Com..... If you mean the value of that field there is no </...> in the XML. Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 $value->getElementsByTagName("name"); $value variable is being used. What is it.. Where is it assigned? Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 16, 2010 Author Share Posted April 16, 2010 here is a snipit from the XML document... <competitioninformation> <ladder name="Battlefield: Bad Company 2 - NA 4v4 Squad Rush"> <ladderlink> <httplink>http://www.alinkgoeshere.com</httplink> <xmllink>http://www.anXMLgoeshere.com</xmllink> </ladderlink> <rank>2</rank> <wins>0</wins> The Battlefield: Bad Company 2 ... etc ... line "value" is what i am trying to pull. Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 That still doesn't state where $value is defined. Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 16, 2010 Author Share Posted April 16, 2010 please see the attached file for the full XML ... i hope this tells you what you are looking for, b/c i am still confused, sorry http://www.teamwarfare.com/xml/viewteam_v2.asp?team=Late+Nite+Commandos Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 16, 2010 Author Share Posted April 16, 2010 OH ! ... i see what you mean ... there is no $value ... i want to know how i pull the Battlefield text in the quotes. sorry for the confusion. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted April 16, 2010 Share Posted April 16, 2010 Asher You seem to be using some custom XML DOM Class. When you use getElementsByTagName(), you give it the Tag Name, not just 'name'. This line will then give you the value of the first occurance of that tag. (I Assume, since i dont now your class). $names = $name->item(0)->nodeValue; -- To people wondering what $value is; It is a class, similar to: http://uk2.php.net/manual/en/function.domelement-get-elements-by-tagname.php -cb- Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 16, 2010 Share Posted April 16, 2010 <?php $url = 'http://www.teamwarfare.com/xml/viewteam_v2.asp?team=Late+Nite+Commandos'; $xml = simplexml_load_file($url); echo $xml->competitioninformation->ladder[0]->attributes(); now of course, the above will always only pull the attribute from the first "ladder" node. changing 0 to 1 will give the second in the bunch. just depends if this is to be dynamic or static. Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 17, 2010 Author Share Posted April 17, 2010 thank you SO much ... that has worked awesome ... CHEER ! Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 17, 2010 Author Share Posted April 17, 2010 actually ... ran into an new issue ... instead of pulling both ladders at once, how can i pull on ladder at a time, how do i differentiate the 2 in code form. I want to pull info from the first ladder, then (separately) pull info from the second ladder ... then the league is easy b/c there is only one. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 17, 2010 Share Posted April 17, 2010 the code provided will pull only the first ladder. does not pull both. and as noted in my post, switching the [0] to [1] will give you the second ladder. now, this is a static method of pulling these values from the xml; you can always use foreach to loop through and display dynamically that way. Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 17, 2010 Author Share Posted April 17, 2010 right ... ok can i use the { } to buch many echo together ? or do i use the attributes area for that ? Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted April 17, 2010 Share Posted April 17, 2010 sorry, my post got messed up. bbcode stepped in and did its thing. what i meant was if you change [ 0] to [ 1], you can see the second ladder value in the xml file. and i don't follow what you're asking. what exactly are you trying to achieve, and then maybe i can help you. do you only want to pull the first ladder, or are you now looking to be able to pick and choose? and will there ever be more than 2 ladder values in any given xml file? Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 17, 2010 Author Share Posted April 17, 2010 - please see the attached file for the code i currently have... - here is the result from the code ... http://testing.a3designs.com/ as you can see the issue i have run into is that the ladder name shows up fine on the first ladder, but there is an issue with the second, and the league is also fine. Yes there can always be more than 1 ladder/league, etc... in these XMLs Thanks for your help. [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 17, 2010 Share Posted April 17, 2010 <?php $url = 'http://www.teamwarfare.com/xml/viewteam_v2.asp?team=Late+Nite+Commandos'; $xml = simplexml_load_file($url); echo $xml->competitioninformation->ladder[0]->attributes(); ?> This will pull the first ladder only, as stated by MrMarcus. I'm assuming to pull the second ladder.. You'd do the same code.. but using echo $xml->competitioninformation->ladder[1]->attributes(); instead. This will pull the second ladder? Sorry if I'm wrong, I haven't ever worked with XML Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 17, 2010 Author Share Posted April 17, 2010 that is correct ... but it only pulls the ladder name ... I want to pull all the details for that ladder ... wins, losses, forfeits, etc... Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted April 17, 2010 Share Posted April 17, 2010 I dont know exactly whats being displayed, but alot of info is on there. With an error at the bottom. Fatal error: Call to a member function tablerender() on a non-object in /home/ash71360/public_html/SITE_LNC/e107_plugins/A3-TWL_menu/A3-TWL_menu.php on line 118 Quote Link to comment Share on other sites More sharing options...
Ash3r Posted April 17, 2010 Author Share Posted April 17, 2010 I am not worried about that (also has been fixed) ... I am trying understand how to display the info for both ladders seperately. Quote Link to comment 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.