I have been requested to create a file which will act like an XML page (expandable tree-like structure). I have been given the following requirements:

1. End user requires that the page be an xml file. No problem there, I know enough (barely) to do that.

2. Request that, if possible, I should hide the tag information. That is, instead of showing this:

<heading>Hello there!</heading>

, I should simply have it read, in that kind of situation, "Hello there!".

As far as I know, it is impossible to do this (remove the tags from the display) in XML. However, I am under the (possibly mistaken) impression that an XSL stylesheet can transform the basic xml page into something resembling ordinary html. So, basically, is there any guaranteed way, in HTML alone, to imitate the expandability of an XML page? I've searched google about it, but everything I came up with appeared to rely on either php code or javascript, and I cannot count on either of those to be present in the end user's system. So, my questions are:

A) Is it possible, using only html, to imitate this functionality?
and
B) If so, can anyone suggest a good place to discover information concerning how to do this?

Thank you for your consideration,
-EnderX

You could do it, but you'd need some Javascipt to create the expand/collapse buttons, and (probably) some XSL to convert the XML into HTML.

Non-JS alternatives would involve some messy backend stuff with query strings... (and heck, if you're using client-side XSL transformations, getting hold of the query string is like getting hold of the holy grail [but it is possible])

PHP doesn't have to be present in the end user's system, it's server-side. But like I said, it will be messy witout Javascript...

Member Avatar for GreenDay2001

Yes you would really have learn XSL & JavaScript. javascript could give you best results.

I have always been told not to rely on using Javascript, as it is possible that the files I create might be viewed by someone with Javascript functionality turned off in their system. Is there absolutely no way to do this without resorting to Javascript?

Yes, there is, you can do it all with server side scripting, or alternatively, make lots of files that represent every potential state that your tree can be in.

You could even do it with
Server Parsed XML, but you'd still need a way of maintaining state (possibly a session cookie, or a huge dynamic key that is generated by a server side script and affects the XML file returned by a page request at each click).

If you only want one area (node) of the tree to be expanded at a time, then I suppose it's easier, but it still requires a bit of href logic on your part when writing or generating the pages.

Why not show the tree expanded, and if Javascript is running on the computer, use it to collapse all of the unwanted nodes? That way, users who don't use JavaScript will have alot to read, and user's with JavaScript will only have a slight advantage.

I don't like using Javascript for anything that represents a "core" functionality.

EDIT: I should add, relying on client side XSL transformations is worse than relying on JavaScript! IF you are using XSL, look at the Xalan application (www.apache.org) if you want to generate pages one-time on your computer; or the PHP XSLT module if your pages might change frequently.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.