Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

XML question - any experienced XML users?

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.

[code][blue]

Then display this

Dislpay this

[/blue][/code]

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:

[code][blue]

Then display this


Otherwise display this



[/blue][/code]

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

Comments

  • pbarbaliaspbarbalias Posts: 6Member
    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.
    :
    : [code][blue]
    :
    :

    Then display this

    :
    :

    Dislpay this

    :
    : [/blue][/code]
    :
    : 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:
    :
    : [code][blue]
    :
    :
    :

    Then display this

    :
    :
    :

    Otherwise display this

    :
    :
    : [/blue][/code]
    :
    : 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
    :

  • ITAITA Posts: 463Member

    : 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!"

  • pbarbaliaspbarbalias Posts: 6Member
    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!"
    :
    :

  • ITAITA Posts: 463Member
    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!"

  • pbarbaliaspbarbalias Posts: 6Member
    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!"
    :
    :

  • ITAITA Posts: 463Member
    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!"

Sign In or Register to comment.