XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-178.btcentralplus.com)
Date: June 12, 2012 11:05PM

heres how it appears if I drag n drop the xml file onto the browser window






and heres how it appears if I try to run it under wamp, (i.e localhost/country.xml)





there must be a simple explanation behind it - which should make it clear why this is happening. If somebody knows, please get back to me on this asap.


This was an xml file created as part of some University coursework few years ago - I'm going over my old academic material for a refresher etc. I created an xsd and a dtd file against which to validate this xml file and it validates.

In a nutshell, the xml file holds information about ' Tour Packages ' in the United States. The root tag is 'country' , and a country is a complex type obviously.

Each Tour Package has a name based on the region of the USA you wish to vacate to, so in the screenshot above - the first package name is called 'East Coast Discovery' and it has its own airport destination, as well as a package price.

Each Tour Package encompasses a number of 'destinations' (under the tag 'destination') which in turn have their own sets of activity (basicaly sights, places, things to do etc)


Hopefully by viewing xml1.jpg everything will become self explanatory.



All I want to know is why does the 'tree structure' not appear when I run the xml file under localhost (wamp running) , and only when I drag n drop it out onto a seperate browser window pane.


What is causing this to happen and is there a way around this ?

I posted this issue earlier on tek-tips.com but may not have explained the issue or phrased it too well.

heres the link [www.tek-tips.com]

please get to me on this asap folks


sincerest regards

c0deMonkey2012

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: stevenmartin99 (Moderator)
Date: June 12, 2012 11:10PM

can we see the source of the xml file?

where is the Doc Header for XML etc?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-178.btcentralplus.com)
Date: June 12, 2012 11:21PM

i don't know what you mean by that stevemartin99, but if it helps you sleep better - the XML you see in the screenshot validates fine against its respective DTD.


it also validates fine against its respective xsd. (that file was called 'country.xml' not 'country_to_dtd.xml'


heres the XSD code


<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="[www.w3.org];

<xsd:element name="country" type="countryinfo" />
<xsd:comlpexType name="countryinfo" />
<xsd:sequence>
<xsd:element name="TourPackage" type="PackageInfo" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="PackageInfo">
<xsd:sequence>
<xsd:element name="CountryName" type="xsd:string"/>
<xsd:element name="PackageName" type="xsd:string"/>
<xsd:element name="AirPortDestination" type="xsd:string"/>
<xsd:element name="PackagePrice" type="xsd:string">
<xsd:element name="destination" type="destinationInfo" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="destinationInfo">
<xsd:sequence>
<xsd:element name="destinationName" type="xsd:string"/>
<xsd:element name="activity" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType
</xsd:element>
</xsd:schema>

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-178.btcentralplus.com)
Date: June 12, 2012 11:26PM

why duplicate xml files , one validating against an xsd and the other against a dtd ?


well - debugging/testing purposes. Obviously all I have to do is change the top few lines in the xml file itself so it would reference either the dtd or the xsd.

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-178.btcentralplus.com)
Date: June 12, 2012 11:38PM

Sadly it wont let me copy/paste my xml file on here - apparently there was a 'word' which was not permitted or something, and I would have to contact the administrators about it.


instead - ive provided the files as a download (.rar)

here is the link stevemartin9...


[uploading.com]

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: stevenmartin99 (Moderator)
Date: June 12, 2012 11:50PM

are php short tags enabled?

it must be disabled for xml compatability.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-182.btcentralplus.com)
Date: June 13, 2012 10:32AM

i see. But ive had it disabled by default throughout my ordeal :-|

so i tried the opposite - out of boredom heh.


clicking on the wamp icon at the bottom right hand corner of the screen (on the taskbar startup progs) i went straight to php settings and saw 'short open tag' - but WITHOUT a tick next to it.


this has been the default setting I believe.

without touching that - i opened up the php.ini file and saw that the 'short-open-tag' setting was indeed set to off.


I closed that php.ini file and clicked again on the wamp icon, and this time under php settings - selected the 'short open tag' option (so it now had a tick beside it).

wamp restarts obviusly, for changes to take effect.

opening up the php.ini file again, and now we can see that short-opten-tag = on.


i will now disable it and try again to see if it works.


And lo behold - same problem, xml file opens up as it appears in screenshot 2, no tree structure with the user-defined xml tags and collapseable branches.

this is not good :-|


what now ?

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: dwt (---.dsl.teksavvy.com)
Date: June 13, 2012 08:23PM

Please pardon me for jumping in but I had a similar problem a few months ago. In my case, the server was not sending the correct mime-content for the xml page. As a result, two different browsers, using differnt type detection approaches rendered the page in a manner almost identical to your images. Don't know if this applies in your situation but you can check that the http header has an appropriate content-type using firebug or some similar tool.

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: stevenmartin99 (Moderator)
Date: June 13, 2012 08:37PM

thats why i wanted to see the DTDsmiling smiley

I agree , you can modify the mime types in the httpd.conf

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-182.btcentralplus.com)
Date: June 14, 2012 01:52AM

steve the DTD is here


[uploading.com]


it won't let me paste it here - because theres a 'word' that upsets the moderators/adminstrators.

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-182.btcentralplus.com)
Date: June 14, 2012 02:27AM

So - when a file with a .xml extension is run from the actual computer file system (i.e file:///C:/wamp/www/country_to_dtd.xml )

it works, and you see the well formed correct layout of the xml with its respective user-defined tags, as in screenshot 1.



when its run on localhost - tags dont appear and as a result theres no tree structure, heck to the naked eye its not even an xml file is it ?


i could use simpleXML and the DOM query stuff to read in an xml file and pull out the values one by one and output them onto the screen - thats what you would see in screenshot 2.


but i am not doing that lol

all im doing is trying to VIEW the frigging xml file in localhost the way its viewed on a browser via file system path.



Now, I have no shame in admitting this fellas - but im a relative newbie to all this 'mime types' stuff - not that it hasn't created an oppertunity for me to learn new stuff, its just that ive found myself now reading up on http headers, encoding, meta-data heh


computers should ONLY ever be allowed to be in close proximity to a human being - if that person is a certified computer scientist :-)


oh wait - i am a computer scientist (Bsc level) lol

and look at me ! i haven't the slightest idea as to whats going on here with regards to this problem :-D




p.s - what do I need to edit in the httpd.conf file then ?

Options: ReplyQuote
Re: XML File appears as plain text without tags on browser from localhost path - why ?
Posted by: c0deMonkey2012 (---.range86-182.btcentralplus.com)
Date: June 14, 2012 02:54AM

i think I know what I have to do now folks - figured it out myself.


notice, i said i ' think ' i know what I have to do now - so i'll be okay from here on lol.


if you see smoke coming out of my computer and my hair on fire and the cat jumping out of the top floor window - i've probably done something 'not good' :-D

Options: ReplyQuote


Sorry, only registered users may post in this forum.