Jump to content

Recommended Posts

Hi,

I have following problem:

I'm getting xml data by html get method. For ex.

http://www.somesite.com/index.php?i...hool=123&name=A

When I send this info I'm getting response data as xml

Now my question and problem is:
After getting this xml tree I want to parse it and write to db.
Or after getting it I want to save somewhere in server as *.xml file.

Is it possible?
Link to comment
https://forums.phpfreaks.com/topic/30431-proceed-data-obtained-by-http-get-method/
Share on other sites

<?xml version="1.0" encoding="UTF-8"?>
<Auction>
<Branch id="1">
<Category id="2">
<Name>Gold</Name>
<Rings id="21">
<Name>Special Gold Ring</Name>
<Product id="926395">
<Process>
<AuctionData>
<Competitor ID="31" Type="1" country="US">
<Name>James Miller</Name>
</Competitor>
<Competitor ID="102" Type="1" country="FR">
<Name>Franck Pardeau</Name>
</Competitor>
<Competitor ID="22" Type="2" country="US">
<Name>Linda Harwood</Name>
</Competitor>
</AuctionData>
<DateInfo>
<AuctionDate>2006-12-12 14:45:00</AuctionDate>
</DateInfo>
</Process>
<Status StatusId="1">Finished</Status>
<Result>
<Value Type="LAST" Currency="1">23,456.12</Value>
</Result>
<BidsHistory>
<Bids type="1" startingPrice="15,000" currency="1">
<Bid Count="4" Rise="2,000">23,456.12</Bid>
<Bid Count="3" Rise="2,000">21,456.12</Bid>
<Bid Count="2" Rise="2,000">19,456.12</Bid>
</Bids>
</BidsHistory>
</Product>
</Rings>
</Category>
</Branch>
</Auction>

This is the xml data which I'm getting by http get method.

http://www.somesite.com/index.php?branch=1&Category=2&Date=2006-12-12
OK. I asked the question a little wrong I think.

Now our information supplier has a form which gave us direct link to the file where I'm
using to send form datas. I mean <form action="direct link to file out of my server" method="get">
I meant I'm getting data by this way.

So I'm asking after opposite server responded me the xml feed which I provided above, how can I generate, proceed this data with php? I want to parse and write to db or save it as xml file in my database.

That's why I asked if it is possible.
Well, without seeing ANY code, I'll assume youve got this xml in a variable ($xml) somehow. To put it in a database...

[code]
INSERT INTO tbl (xml) VALUES ('$xml');
[/code]

To parse it, you will either need to look at php's [url=http://php.net/simplexml]simplexml[/url]extension for php5 or the [url=http://php.net/xml]xml[/url] otherwise.
All right.

Look at the little example given here:
http://www.tbsistem.com/sample

When I click Submit, I'm getting the data like this one.

I can save it as xml file from browser, but i dont want to do it like this.
I want to save it auto somewhere in server and after saving run my cron to parse, generate it.
on the response.php page
you need to give it an XML header and then it will automatically save so to speak

I don't know how response.php works...
like thorpe stressed, we need code

but on response.php you should put
header("Content-type: text/xml");

and get rid of everything else
I.E
the body tag
the html tags
the meta tag
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.