473,467 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

hai experts,regarding php-xml

4 New Member
Hi php-xml masters there ,warm greetings from this budding php guy..I'm new to this..and now caught up with a problem..

THE FOLLOWING is my code to extract data from a php class "simple.php"
My task is to generate xml documents ,that i'm able to do now.


<?php

class compile1
{
function compile1()
{
include "simple.php";
$obj = new request;
$this -> filename = $obj -> filename;
$this -> filepath = $obj -> filepath;
}
}
$obj1=new compile1;
$dom=new DOMDocument("1.0");
$dom->formatOutput = true;
header("Content-Type:text/plain");

$root = $dom->createElement("request");
$dom -> appendchild($root);

$filename = $dom -> createElement("filename");
$root -> appendchild($filename);
$text = $dom->createTextNode($obj1->filename);
$filename -> appendchild($text);


$filepath = $dom->createElement("filepath");
$root -> appendchild($filepath);
$text = $dom -> createTextNode($obj1->filepath);
$filepath -> appendchild($text);
echo $dom -> saveXML();

?>

the simple.php file (class) is

<?php

class request
{
public function request()
{

$this->filename="fibonacci.php";
$this->filepath="15.156.12.244/dirname";
}

}
?>

And output is as follows

<?xml version="1.0" ?>
- <request>
<filename>fibonacci.php</filename>
<filepath>15.156.12.244/dirname</filepath>
</request>

Now here are my problems..

1.The tags in this XML output are hard coded.I want to make it dynamic i.e ,tags should be dynamically generated based on the class provided .

2.I ve to store this output in a file (.xml) and i have to retrieve each value of node by storing them against any variables ,so that other functions can access this xml elements using those variable names..

I tried diffrent ways and still trying.
Any masters and experts reading this , please help.
regards
rahul..
Mar 7 '08 #1
7 1364
ronverdonk
4,258 Recognized Expert Specialist
It would help a lot if you respected the people you are looking to get help from and put your code within the appropriate code tags! See the Posting Guidelines on that.

moderator
Mar 7 '08 #2
rahulragav
4 New Member
It would help a lot if you respected the people you are looking to get help from and put your code within the appropriate code tags! See the Posting Guidelines on that.

moderator
Dear sir,
After reading your reply to my post,i realise my mistake. I always have great respect and regards to everyone.Since i was posting for the first time,i was confused as to how formal it should be.. And i believe it's my improper use of certain words that created a feel of some disrespect..But it was not intentional.
Once again i plead sorry and assure to correct myself in future.
regards,
rahul.
Mar 11 '08 #3
dlite922
1,584 Recognized Expert Top Contributor
I shouldn't have to do this for you... but...

[PHP]
<?php

class compile1
{
function compile1()
{
include "simple.php";
$obj = new request;
$this -> filename = $obj -> filename;
$this -> filepath = $obj -> filepath;
}
}

$obj1=new compile1;
$dom=new DOMDocument("1.0");
$dom->formatOutput = true;
header("Content-Type:text/plain");

$root = $dom->createElement("request");
$dom -> appendchild($root);

$filename = $dom -> createElement("filename");
$root -> appendchild($filename);
$text = $dom->createTextNode($obj1->filename);
$filename -> appendchild($text);


$filepath = $dom->createElement("filepath");
$root -> appendchild($filepath);
$text = $dom -> createTextNode($obj1->filepath);
$filepath -> appendchild($text);
echo $dom -> saveXML();

?>[/PHP]

the simple.php file (class) is
[PHP]
<?php

class request
{
public function request()
{
$this->filename="fibonacci.php";
$this->filepath="15.156.12.244/dirname";
}
}
?>[/PHP]
Mar 11 '08 #4
dlite922
1,584 Recognized Expert Top Contributor

1.The tags in this XML output are hard coded.I want to make it dynamic i.e ,tags should be dynamically generated based on the class provided .
First: don't need to use two classes it looks like, create one class and create an associative array as the data member. to traverse and output the XML, use foreach().

2.I ve to store this output in a file (.xml) and i have to retrieve each value of node by storing them against any variables ,so that other functions can access this xml elements using those variable names..
I have no idea what you mean here by storing them against any variable.

please elaborate.
Mar 11 '08 #5
rahulragav
4 New Member
First: don't need to use two classes it looks like, create one class and create an associative array as the data member. to traverse and output the XML, use foreach().



I have no idea what you mean here by storing them against any variable.

please elaborate.
Dear Sir,
Thank you very much, for reading and replying to my problem.

"storing them against any variable" - the actual task is to access the xml data.

If i m using simple xml, the coding just extracts the xml data and display it in the browser. But ,my project involves creation of an interface that provide this xml data input to an adaptor.
So along with the xml data extraction, we have to assign them to certain variables.Then the adaptor will be able to use this data by calling those variables (arguments of the function call)
Very sorry sir,for i am not able to show the adaptor code here as it is being handled by a different team.
regards,
rahul.
Mar 13 '08 #6
rahulragav
4 New Member
I shouldn't have to do this for you... but...

[PHP]
<?php

class compile1
{
function compile1()
{
include "simple.php";
$obj = new request;
$this -> filename = $obj -> filename;
$this -> filepath = $obj -> filepath;
}
}

$obj1=new compile1;
$dom=new DOMDocument("1.0");
$dom->formatOutput = true;
header("Content-Type:text/plain");

$root = $dom->createElement("request");
$dom -> appendchild($root);

$filename = $dom -> createElement("filename");
$root -> appendchild($filename);
$text = $dom->createTextNode($obj1->filename);
$filename -> appendchild($text);


$filepath = $dom->createElement("filepath");
$root -> appendchild($filepath);
$text = $dom -> createTextNode($obj1->filepath);
$filepath -> appendchild($text);
echo $dom -> saveXML();

?>[/PHP]

the simple.php file (class) is
[PHP]
<?php

class request
{
public function request()
{
$this->filename="fibonacci.php";
$this->filepath="15.156.12.244/dirname";
}
}
?>[/PHP]


Thanks a lot sir,for viewing and correcting my post.
I assure you that in future i ll try to learn more and improve my ways of posting in forums.
Mar 13 '08 #7
ronverdonk
4,258 Recognized Expert Specialist
Thanks a lot sir,for viewing and correcting my post.
I assure you that in future i ll try to learn more and improve my ways of posting in forums.
Okay, that is allright. See you again.

Ronald
Mar 14 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Francis Lavoie | last post by:
Hello I have some questions regarding webframework, I must say that I quite lost and these questions are basicly to help me understand the way it work. I have some knowledge with PHP and JSP....
28
MMcCarthy
by: MMcCarthy | last post by:
Policies below superceded by FAQ Post Course Work Questions and Answers. ADMIN
4
hsriat
by: hsriat | last post by:
Got an issue regarding this... As said above (same as what php.net says), if we use mysql_pconnect(), it doesn't create more connections, if the connection parameters are same as the existing...
5
by: jennic | last post by:
Hi, I have an online shop that uses Sunshop php shopping cart and I have attempted to get help through their forum but no-one responds with assistance. I need to install a tracking code on my site...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.