Internet Development

Moderators: None (Apply to moderate this forum)
Number of threads: 1024
Number of posts: 1892

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
XML question - any experienced XML users? Posted by tvienti on 5 Sept 2004 at 12:55 PM
This might not be the first place for this post but I was hoping somebody could help me with an XML question. I'm designing a set of functions that will parse out custom XML tags in an other-wise purely HTML file, and perform logic on them.

One example that I'm trying to do is a way to use XML tags to perform conditional branching of the HTML in the form of if statements.


<if condition="...">
	<p>Then display this</p>
<else>
	<p>Dislpay this</p>
</if>


My question is - is that valid XML? It doesn't look right, since else contains a child element but doesn't have a closing tag. I was thinking this might be XML compliant, but it's uglier:


<if condition="...">
	<if_true>
		<p>Then display this</p>
	</if_true>
	<if_false>
		<p>Otherwise display this</p>
	</if_false>
</if>


Anybody out there have input on what might be a good approach to this problem? Am I on the right track of is there an easier way? I'm open to suggestions. Thanks in advance.

T
Report
Re: XML question - any experienced XML users? Posted by pbarbalias on 25 Oct 2004 at 8:03 AM
You should consider using XSLT files along with your XML files.

Remember:
XML is the data
XSLT is the template that will be used to PRESENT your data.

The xslt has a huge amount of functions including IF/Then/else logical checks and stuff..

PB

: This might not be the first place for this post but I was hoping somebody could help me with an XML question. I'm designing a set of functions that will parse out custom XML tags in an other-wise purely HTML file, and perform logic on them.
:
: One example that I'm trying to do is a way to use XML tags to perform conditional branching of the HTML in the form of if statements.
:
:

: <if condition="...">
: 	<p>Then display this</p>
: <else>
: 	<p>Dislpay this</p>
: </if>
: 

:
: My question is - is that valid XML? It doesn't look right, since else contains a child element but doesn't have a closing tag. I was thinking this might be XML compliant, but it's uglier:
:
:

: <if condition="...">
: 	<if_true>
: 		<p>Then display this</p>
: 	</if_true>
: 	<if_false>
: 		<p>Otherwise display this</p>
: 	</if_false>
: </if>
: 

:
: Anybody out there have input on what might be a good approach to this problem? Am I on the right track of is there an easier way? I'm open to suggestions. Thanks in advance.
:
: T
:

Report
Re: XML question - any experienced XML users? Posted by ITA on 23 Feb 2005 at 7:10 AM

: Remember:
: XML is the data
: XSLT is the template that will be used to PRESENT your data.


I'm considering making a website which will make use of both of these technologies. I've worked with basic XML but never XSL.

What I want to know is can I do this? I want to use XML to represent the data in my site, then I'll use XSL to format the data and show it to the user. Also how well supported is XML by browsers now? A while back it didn't seem to have that much support. Has that changed now?

Please help, many thanks

ITA


"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"

Report
Re: XML question - any experienced XML users? Posted by pbarbalias on 23 Feb 2005 at 9:31 AM
Hello there.
First thing that you should consided is that you need a scripting language on the server to do that.

I work with ASP usually.

There are methods to do this,
actually 1 line of code,
that you give asp the xml path and the xsl path and it transforms it to HTML.

Now, you don't have to worry about presenting XML on each browser. The output after the transformation will be pure HTML.

Let me know if you need something more so I can point to you some specific solutions examples.

Regards,
Panos

:
: : Remember:
: : XML is the data
: : XSLT is the template that will be used to PRESENT your data.
:
:
: I'm considering making a website which will make use of both of these technologies. I've worked with basic XML but never XSL.
:
: What I want to know is can I do this? I want to use XML to represent the data in my site, then I'll use XSL to format the data and show it to the user. Also how well supported is XML by browsers now? A while back it didn't seem to have that much support. Has that changed now?
:
: Please help, many thanks
:
: ITA
:
:
: "Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"
:
:

Report
Re: XML question - any experienced XML users? Posted by ITA on 24 Feb 2005 at 10:09 AM
Thanks, I'll be using PHP.

Do you know of any good books which I should start off with which are not M$ based (I'm on linux)?

I'm considering buying 'Inside XML' or 'XML for the world wide web' or 'XML in 21 days'. Are there any better ones that you know of, or can you recommend one of these?

thx,

ITA


"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"

Report
Re: XML question - any experienced XML users? Posted by pbarbalias on 24 Feb 2005 at 4:51 PM
Well,
I am using ASP, and the book that showed me the most important stuff was ASP & XML from Wrox publishing. They have the best technical books.

I am sure something similar exists for PHP.

What you should really be carefull about is not to buy a book that spends 30 chapters on what is XML, what structure it has, why is it better than HTML and bla bla bla...

Most of the chapters are useless. XML is a tree structured way to describe and contain data. XSLT will help you presenting your data in many different ways. PHP will be used only to do the compiling of the HTML before showing it to the browsuer. If you know the basics of XML, prefer to buy a book for XSLT directly.

Let me know if you need to know anything else,
regards,
Panos

: Thanks, I'll be using PHP.
:
: Do you know of any good books which I should start off with which are not M$ based (I'm on linux)?
:
: I'm considering buying 'Inside XML' or 'XML for the world wide web' or 'XML in 21 days'. Are there any better ones that you know of, or can you recommend one of these?
:
: thx,
:
: ITA
:
:
: "Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"
:
:

Report
Re: XML question - any experienced XML users? Posted by ITA on 25 Feb 2005 at 9:03 AM
thx,

ITA



"Let us smite the evil slime eating hordes who may befall us on our quest to be the ultimate programmers of the known universe!"




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.