XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 1st, 2004, 09:26 PM
EH_Canadain EH_Canadain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Canada, Ontario
Posts: 131 EH_Canadain User rank is Private First Class (20 - 50 Reputation Level)EH_Canadain User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 5 h 11 m 41 sec
Reputation Power: 5
Send a message via MSN to EH_Canadain
teamwarfare.com xml

I'm trying to parse the data contain in the xml link for a gaming clan

Link to xml btw the last 3 letters are @ss

another problem i ran into is I unsure how to display
tag's with the = included in the tag name.
( Example <ladder name="America's Army 2v2 Combat"> )

again another problem is geting the tag's that contain links to output as html links

below is what I gathered in code for php it displays some of the data from the xml but seems to mostly echo the tag data

can anyone code something up? it be a great help to the clans that use this rather then bashing there brains out like i have trying to understand this

Code:
<?

// arrays to associate XML elements with HTML output 
$startTagsArray = array(

'TEAMINFORMATION' => '',
'NAME'        => '<BR>NAME: ',
'URL'         => '<BR>URL: ',
'EMAIL'       => '<BR>EMAIL: ',
'STATUS'      => '<BR>STATUS: ',
'FOUNDER'     => '<BR>FOUNDER: ',
'DESCRIPTION' => '<BR>DESCRIPTION: ',

'COMPETITIONINFORMATION' => '<BR> ',
'HTTPLINK'     => '<BR>HTTPLINK:',
'XMLLINK'      => '<BR>XMLLINK: ',
'RANK'         => '<BR>RANK: ',
'WINS'         => '<BR>WINS: ',
'LOSSES'       => '<BR>LOSSES:',
'FORFEITS'     => '<BR>FORFEITS: ',

'MATCH STATUS' => '<BR>',
'OPPONENTNAME' => '<BR>OPPONENTNAME: ',
'HTMLLINK'     => '<BR>HTMLLINK: ',
'XMLLINK'      => '<BR>XMLLINK: ',
'MATCHDATE'    => '<BR>MATCHDATE: ',
'MAP NAME'     => '<BR>MAP NAME: ',
'PLAYER NAME'  => '<BR>PLAYER NAME: ',
'JOIN DATE'    => '<BR>JOIN DATE: ',
'POSION'       => '<BR>POSION: ',
'HTMLLINK'     => '<BR>HTMLLINK: '
);

$endTagsArray = array(
'LINE' => ','

);

// array to hold sub-totals
$subTotals = array();

// XML file
$xml_file = "http://www.teamwarfare.com/xml/viewteam_v2.asp?team=E%2DZ+Just+Kicked+Your+***";

// parse document
$doc = xmldocfile($xml_file);

// get the root node
$root = $doc->root();

// get its children
$children = $root->children();

// start printing
print_tree($children);

// this recursive function accepts an array of nodes as argument,
// iterates through it and: 
//   - marks up elements with HTML
//   - prints text as is
function print_tree($nodeCollection)
{
   global $startTagsArray, $endTagsArray, $subTotals;

   foreach ($nodeCollection as $node)
   {
     // how to handle elements
     if ($node->type == XML_ELEMENT_NODE)
     {
       // print HTML opening tags 
       echo $startTagsArray[strtoupper($node->tagname)];   
   
       // recurse
       $nextCollection = $node->children();
       print_tree($nextCollection);

       // once done, print closing tags
       echo $endTagsArray[strtoupper($node->tagname)];
     }
     // how to handle text nodes
     if ($node->type == XML_TEXT_NODE)
     {
       // print text as is
       echo($node->content);
     }

     // PI handling code would come here
     // this doesn't work too well in PHP 4.1.1
     // see the sidebar entitled "Process Failure" 
     // for more information
   }
}

// this function gets the character data within an element
// it accepts an element node as argument
// and dives one level deeper into the DOM tree 
// to retrieve the corresponding character data
function getNodeContent($node)
{
   $content = "";
   $children = $node->children();
   return $content;

}

?>

Reply With Quote
  #2  
Old August 18th, 2004, 11:41 AM
EH_Canadain EH_Canadain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Canada, Ontario
Posts: 131 EH_Canadain User rank is Private First Class (20 - 50 Reputation Level)EH_Canadain User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 5 h 11 m 41 sec
Reputation Power: 5
Send a message via MSN to EH_Canadain
wow... no one has a answer!

Reply With Quote
  #3  
Old August 18th, 2004, 02:28 PM
NotGoddess's Avatar
NotGoddess NotGoddess is offline
Kung-fu Kitty
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 350 NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 6 h 9 m 2 sec
Reputation Power: 10
Send a message via AIM to NotGoddess
Correct. No answer, at least from me, because I could not decipher your question when I read it when first posted. If you can provide clarification, maybe I can answer, but it looks like you are asking for php help, which is not my specialty.

For your short questions, in <ladder name="America's Army 2v2 Combat">
'name' is an attribute of the 'ladder' tag. In xsl you would access that via @
e.g. <xsl:for-each select="//ladder"><xsl:value-of select="@name"/></xsl:for-each>

See this post for some search samples, or just read any basic xml tutorial (try topxml.com or google the term).

You can usually use xsl:copy-of in place of xsl:value-of to correctly render an html link in a xml file.

....now you go answer my question

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > teamwarfare.com xml


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT