How to add XML to a Web Page

Hi - I was looking for a tutorial or a "How To" in order to learn how add 1 small XML call to a web page of ours. It is 2-lines of  XML code (our Key and a part number) and the XML returned is simply a "Quantity in Stock" that we want to display on our web page)
Although we are XML Dummies, we have done PHP coding with MySQL, Web development, have done Web Reply Forms, etc. and do command-level Linux. So we are thinking "How hard could XML be?"  If it matters, we are doing this on Linux/LAMP Servers, NOT Microsoft/IIS.

Before we start digging around Googling & Reading books, I thought someone might point us in the right direction ...

Thanks all !
- B
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
XML is not executable code--it is markup language. When you say "add 1 small XML call" do you mean that you want to call a web service?
bleggeeAuthor Commented:
Hi Kaufmed - Specifically, I want to get a part's current "Quantity in Stock" printed on my web page ... per my Vendors XML, which looks like this:
*** REST Quantity Check ***
To use the REST option, you will need to access the ‘quantitycheck script by sending XML to

The XML sent will need to use the POST method via port 443 (the default port for https). The
product, the product identifier (‘products_model’) and the stock needed should be provided in an XML block like this:
For example, to find out if there is enough stock to order 3 units of a product with the
‘products_model’ 1234AB, and your store key is 1a2aa3456aaaa789a0a123456a7a890a, you
would need to send the following XML:

To the following url

The following XML will be returned:


If the item is out of stock, a quantity of 0 will be returned:


*** SOAP Quantity Check ***
If you are familiar with SOAP and would like to use this protocol to check quantity, simply go to
the following url:
Click on WSDL link to view WSDL (web service description) for the service.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Gertone (Geert Bormans)Information ArchitectCommented:

What you want to do is access a web service from your page.
So there is two layers of functionality you have to develop
1. Access the webservice
2. Access the XML returned by the webservice

1. The webservice offers you two options to get the data

1.A. SOAP is a complex beast. Simply too much for a task like this. It accepts requests hidden in a SOAP envelope It returns responses, hidden in a different SOAP envelope. It is a bit like sending lettres. The outside is uniform: an envelope, an address and a stamp. But you need to unpack it in order to read. For that you either need to hack the XML based SOAP envelope, or use a SOAP library. I don't recommend that you use it in this project (but PHP has a pretty goed soap library

1.B. REST. is similar to SOAP but a lot simpler. You basically send a request (preferably http GET) and you get a representation of the data back. The representation often (as in this case) is an XML document. Go for this approach here

The service (I just checked) seems to require a http POST. This means that you need a http client in your code that can do a  http POST request. Now you have to make a decision. Do you process this client side or server side. You can do both. Given that you need to do a http POST and you need to take different browsers into account, I would go for server side. You can do JavaScript httpPost, no problem. PHP on the server seems more elegant to me.

2. Once the XML is returned to you. There are a zillion ways of getting to the actual value. Since we have just decided that you are going to do a server side PHP for this: there is XSLT for complex transforms (you don't need it here) There is XPath access to a DomDocument. And there is simpleXML. Have a look at the latter. It will serve your purpose well.

There is a hybrid approach you might like. Use the httpPost from the PHP server side and post the XML (as a data island or alongside ) the HTML. And process the XML in the HTML page client side. Again, you will hit some cross browser issues. The XML is too simple and too small to gain a benefit from that approach

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gertone (Geert Bormans)Information ArchitectCommented:
here is a link to the simpleXML link
(note that you need to explicitely enable it for older PHP)
Gertone (Geert Bormans)Information ArchitectCommented:
for getting access to the REST service, you can use the http client library
but you need to explicitely add it to your install
Gertone (Geert Bormans)Information ArchitectCommented:
and you are right... as the simpleXML samples tell you: "how hard can XML be?"
the XML is the easy part in this project.
Pulling it off the REST service is the hard(er) coding part
bleggeeAuthor Commented:
Um..thanks. I guess my period did the trick eh? :)
Gertone (Geert Bormans)Information ArchitectCommented:
Welcome, but uhm, did you not accept the wrong answer? :-)
bleggeeAuthor Commented:
Moderator ... let me take a stab at awarding points again ... thx everyone for being on top if this.
MicroPC1 - Yes, that "period" was impressive, I tried & tried using it, but I think I'll have to go with one of the other answers this time :-)
Yeah np,  i actually did post something substantial at first, but after reading your post again I decided to remove it. Unfortunately there's no way to delete a post (as far as I can tell), so I just stuck a period in there.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.