Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 28th, 2003, 09:23 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Article Discussion: Building XML Trees with PEAR's XML_Tree Class

If you have any questions or comments about this article then please post them here.

This forum post relates to this article

Reply With Quote
  #2  
Old June 27th, 2003, 07:24 PM
jezmond5 jezmond5 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 jezmond5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jezmond5
Building XML Trees with PEAR's XML_Tree Class

In this part of your code:
PHP Code:
//instantiate object
$tree = new XML_Tree("history.xml");
$root =& $tree->getTreeFromFile(); 


I have been trying to send the contents of the XML to a variable for use later, in let's say a session variable...
My dilemna it seems, is that when I attempt to print a particular variable (i.e. print $period, it returns nothing?? And I have checked the paths to the XML file, and all checks out.

PHP Code:
 $ch1 =  $root->children//world array
for ($i=0;$i count($ch1); $i++) { 

$ch2 $ch1[$i]->children//continent array
$period $ch2[0]->content;
$name $ch2[1]->content;
$history $ch2[2]->content;
$history=ereg_replace("\'","",$history); 


When i print out the object $ch1 this is what I get in return, so how can I access this information or parse it out?

Array ( [0] => xml_tree_node Object ( [attributes] => Array ( ) [children] => Array ( ) [content] => localhost [name] => db_host ) [1] => xml_tree_node Object ( [attributes] => Array ( ) [children] => Array ( ) [content] => ode [name] => db_name ) [2] => xml_tree_node Object ( [attributes] => Array ( ) [children] => Array ( ) [content] => root [name] => db_user ) [3] => xml_tree_node Object ( [attributes] => Array ( ) [children] => Array ( ) [content] => casey5 [name] => db_pass ) [4] => xml_tree_node Object ( [attributes] => Array ( ) [children] => Array ( ) [content] => c:/apache/htdocs [name] => root_folder ) )

Sincerely,

CJ

Last edited by jezmond5 : June 27th, 2003 at 07:28 PM.

Reply With Quote
  #3  
Old June 27th, 2003, 08:06 PM
jezmond5 jezmond5 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 jezmond5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jezmond5
Thumbs up nevermind, ugh

PHP Code:
 $config_file "../config.xml";
$tree = new XML_Tree($config_file);
$root =& $tree->getTreeFromFile();
    
$ch1 $root->children;
for(
$i=0;$i<count($ch1);$i++) {
     
$ch2[$ch1[$i]->name] = $ch1[$i]->content;



I tried this instead, and I got the results just fine

Sorry,
CJ

Reply With Quote
  #4  
Old July 18th, 2003, 12:11 AM
yesi yesi is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 4 yesi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hello!
Actually I don't have much experience in parsing XML, and I want to ask you how to parse pre-existing XML document (with attributes) using XML tree class
and inserting data attributes into a table from a MySQL database., and convert it again to an XML document (with attributes).

please help me !

Reply With Quote
  #5  
Old December 14th, 2003, 03:01 PM
jezmond5 jezmond5 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 3 jezmond5 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jezmond5
not as hard as it looks

This is very possible to do, but I won't do it for you. I can show you though.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Discussion: Building XML Trees with PEAR's XML_Tree Class


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 1 hosted by Hostway
Stay green...Green IT