Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Post XML data using php
Old 04-18-2008, 05:10 AM Post XML data using php
Experienced Talker

Posts: 33
Name: Ravi B
Location: Mauritius
Trades: 0
Hi,
I need to post an XML string to a url using PHP.
How do i go about do this?

thanks
__________________
Ravi
ravisatan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-18-2008, 06:30 AM Re: Post XML data using php
ooyes's Avatar
Skilled Talker

Posts: 55
Name: Web Design Company
Location: London
Trades: 0
If you need to create XML files in PHP, you can do it without having to create the tags yourself with strings. This code shows you how to use the new_child functions to create an XML file.

PHP Code:
<?
  $doc 
new_xmldoc('1.0');
  
$root $doc->add_root('members');
  
$member $root->new_child('member','');

  
$member->new_child('lastName','John');
  
$member->new_child('firstName','Adams');
  
$member->new_child('contribution','3400');

  
$member $root->new_child('member','');

  
$member->new_child('lastName','Debra');
  
$member->new_child('firstName','Hones');
  
$member->new_child('contribution','2400');

  
$member $root->new_child('member','');

  
$member->new_child('lastName','Jake');
  
$member->new_child('firstName','Tudor');
  
$member->new_child('contribution','1200');

  
$fp = @fopen('members.xml','w');
  if(!
$fp) {
    die(
'Error cannot create XML file');
  }
  
fwrite($fp,$doc->dumpmem());
  
fclose($fp);
  
?>
would create the following XML file.
output
HTML Code:
<members>
  <member>
    <lastName>John</lastName>
    <firstName>Adams</firstName>
    <contribution>3400</contribution>
  </member>
  <member>
    <lastName>Debra</lastName>
    <firstName>Hones</firstName>
    <contribution>2400</contribution>
  </member>
  <member>
    <lastName>Jake</lastName>
    <firstName>Tudor</firstName>
    <contribution>1200</contribution>
  </member>
</members>
__________________

Please login or register to view this content. Registration is FREE
ooyes is offline
Reply With Quote
View Public Profile Visit ooyes's homepage!
 
Old 04-18-2008, 06:33 AM Re: Post XML data using php
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 933
Trades: 7
Hi there,

can you give us an example of exactly whta your trying to do? because 'posting an XML string to a url' is as simple as url.com?xmlstring=$data... so maybe I misunderstood?

cheers
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Old 04-18-2008, 07:01 AM Re: Post XML data using php
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
look up for curl: http://ch2.php.net/manual/en/ref.curl.php#80271
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Post XML data using php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20291 seconds with 12 queries