Jump to content
Sign in to follow this  
djmrman

XML Data

Recommended Posts

HI 

I'm a bit stuck at the moment I have worked out how to pull data from a well-formed XML file but I have a problem when it comes to an XML file that is supplied by some cinema software that i would like to use in an HTML file. It doesn't look well formed so my javascript is not working please see link below 

I need to parse the name duration rating and sessions etc to different divs. I could do this if it was well formed but not sure with how it is formed. Hope someone can help thanks jeremy

http://starlightcinema.asuscomm.com:8090/xml/?xt=name&cid=-1&dt=20190101

The parser script that I have amended is

 

<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "GET",
            url: "data.xml",
            dataType: "xml",
            success: xmlParser
        });
    });

function xmlParser(xml) {
    
        $(xml).find("painting").each(function () {
         $("#container").append('<div class="painting"><img src="images/' + $(this).find("image").text() + '"width="200" height="225" alt="' + $(this).find("title").text() + '" /><br/><div class="title">' + $(this).find("title").text() + '<br/>$' + 
        $(this).find("price").text() + '</div></div>');
                $(".painting").fadeIn(1000);
        });
    }
</script>

Share this post


Link to post
Share on other sites

Why do you think it's not well-formed?  The only issue that an XML validator has is with the initial XML tag with the version.

Share this post


Link to post
Share on other sites

As the data is not separated within the opening and closing tags I thought they needed to have say <date>20190101</date> ect or am I wrong

Share this post


Link to post
Share on other sites

You're wrong, they're using self-closing tags for cinema and session and all of the data is in an attribute.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×