Hi,

I'm trying to include .. ( <?php include("servers.xml"); ?>) within a PHP script.
And because of the first <?xml ...> tag WITHIN the xml file it is tossing off an error.
Anyway around this?
What I'm trying NOT to do is write a huge XML parser to simply display a few lines of already XSL formatted data.

Thanks!

    Does the XML file have any PHP code in it? I assume not... in which case, why are you include()ing it?

    Why not fopen, fread, fclose it instead? or file(), or file_get_contents(), etc. etc.

    You could also just turn off short_tags... which makes your scripts REQURE <?php instead of just <?

      Yeah, I could do that ... I was just hoping I wouldn't have to.

        Actually, I take that back ... the FOpen, etc. route doesn't work.

        Because it actually directly takes the contents of the xml file and ignores any XSL formatting within.

          Um... PHP doesn't automatically do any XSL formatting when you use include() ( unless you're including over HTTP, which you shouldnt' do, and you didn't say you are... ) .

          So either you're mistaken... or you're not describing the problem you're having.

          include()ing a strait XML file ( ie it doesnt' have any PHP in it ) shoudl be the exact same thing as fopen and fread.

            Okay, so how do you suggest I get it to work then?

              Originally posted by superwormy


              Why not fopen, fread, fclose it instead? or file(), or file_get_contents(), etc. etc.

                Doesn't work ... I said this already heh

                  well... WHAT DOESN'T WORK ABOUT IT!?!

                  What EXACTLY is the problem here? include()ing and XML document through the filesystem should be ABSOLUTELY no different than fopen, fread, fclose.

                  Do you get errors? Does it not return anything at all?

                  Maybe you could post some code...

                    I have an XML file.
                    Formatted through XSL.

                    And I simply want to include the XML file in the website, in its formatted form.

                    The problem is with the include is that <? in the xml is throwing it off.
                    So I went with the fopen, etc. way and it does indeed work.
                    But it's literally reading the file and not formatting per the XSL settings.

                    Thanks for the help worm, I appreciate it.

                      OK here is what I don't understand...
                      WHAT is formatting it?

                      It's in its pure XML format, you include() it, suddenly its formatted???

                      The only way this could happen is if you're includeing it over HTTP and the document is XSL formatted on the remote server. Is that the case?

                        Write a Reply...