Hello,
I hope some one can help me with this.
I need to output xml data from a remote server into a pulldown menu.
This is what i already done.
<?
$url = "https://secure.virtuelekassa.nl/api/xml/ideal.asp";
$page = "/ideal.asp";
$request_xml = "<?xml version=\"1.0\" ?>\n";
$request_xml .= "<request>\n";
$request_xml .= "<test>true</test>\n";
$request_xml .= "<type>banklist</type>\n";
$request_xml .= "</request>\n";
$post_string = $request_xml;
$header = "POST ".$url." HTTP/1.0 \r\n";
$header .= "MIME-Version: 1.0 \r\n";
$header .= "Content-type: application/PTI26 \r\n";
$header .= "Content-length: ".strlen($post_string)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Request-number: 1 \r\n";
$header .= "Document-type: Request \r\n";
$header .= "Interface-Version: Test 1.4 \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $post_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
// just for testing
print ("$data");
curl_close($ch);
}
?>
When i run the file i get this.
<?xml version="1.0" encoding="UTF-8"?>
<response>
<type>banklist</type>
<bank>
<bankid>0031</bankid>
<bankname>ABN Amro</bankname>
</bank>
<bank>
<bankid>0081</bankid>
<bankname>Fortis</bankname>
</bank>
<bank>
<bankid>0721</bankid>
<bankname>Postbank</bankname>
</bank>
<bank>
<bankid>0021</bankid>
<bankname>Rabobank</bankname>
</bank>
<bank>
<bankid>0751</bankid>
<bankname>SNS Bank</bankname>
</bank>
</response>
This works fine, but how can i put this $data into a pulldown menu.?
Please if you can help me with a working sample you make me real happy.
Thank you
Hans
2 1444
Hey Hank,
I do something very similar with an xml file and php.
I use preg_match_all and preg_match loops.
Not sure if you are making the xml locally or if it comes from the remote server,
to get the xml, i use this, but the content is already in xml on the remote server
I use this to get my xml page -
// Get the xml page
-
$url = "address where xml is located";
-
$data = implode("", file($url));
-
but once you have the xml in a variable (as above) you can use the below
I think you would want something like this -
-
-
echo "<select name=\"banks\">";
-
// Get each bank
-
preg_match_all ("/<bank>([^`]*?)<\/bank>/", $data, $matches);
-
-
// then go through each to get the bank details from the xml
-
-
foreach ($matches[0] as $match) {
-
-
// get bankid
-
preg_match ("/<bankid>([^`]*?)<\/bankid>/", $match, $temp);
-
$bankid = $temp['1'];
-
-
// get bankname
-
preg_match ("/<bankname>([^`]*?)<\/bankname>/", $match, $temp);
-
$bankname = $temp['1'];
-
-
echo "<option value=\"$bankid\">$bankname</option";
-
}
-
Thank you for repllying,
this is what i was looking for, it works great!
The xml file is recived from a remote server.
Gr. Hans
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sofia |
last post by:
My name is Sofia and I have for many years been running a personals site,
together with my partner, on a non-profit basis. The site is currently not
running due to us emigrating, but during its...
|
by: Robert Maas, see http://tinyurl.com/uh3t |
last post by:
System login message says PHP is available, so I tried this:
http://www.rawbw.com/~rem/HelloPlus/h.php
It doesn't work at all. Browser just shows the source.
What am I doing wrong?
|
by: Gregory Nans |
last post by:
hello,
i need some help to 'tree-ify' a string...
for example i have strings such as :
s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i
need))"""
and i need to...
|
by: Mike Kamermans |
last post by:
I hope someone can help me, because what I'm going through at the moment
trying to edit XML documents is enough to make me want to never edit XML
again.
I'm looking for an XML editor that has a...
|
by: JustSomeGuy |
last post by:
I need to write an new class derived from the list class.
This class stores data in the list to the disk if an object
that is added to the list is over 1K in size.
What methods of the std stl...
|
by: Bob.Henkel |
last post by:
I write this to tell you why we won't use postgresql even though we wish we
could at a large company. Don't get me wrong I love postgresql in many
ways and for many reasons , but fact is fact. If...
|
by: Michael R. Pierotti |
last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$")
Dim m As Match = reg.Match(txtIPAddress.Text)
If m.Success Then
'No need to do anything here
Else
MessageBox.Show("You need to enter a...
|
by: skumar434 |
last post by:
i need to store the data from a data base in to structure
.............the problem is like this ....suppose there is a data base
which stores the sequence no and item type etc ...but i need only...
|
by: Alan Mailer |
last post by:
A project I'm working on is going to use VB6 as a front end. The back
end is going to be pre-existing MS Access 2002 database tables which
already have records in them *but do not have any...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
Brilliant technology helping those most in need Inbox
Reply
U S Contractors Offering Service A Non-profit
show details
10:37 pm (1 hour ago)
Brilliant technology helping those most in need ...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |