dcsimg
www.webdeveloper.com
Results 1 to 11 of 11

Thread: Loading xml file ion JavaScript to a div tag

  1. #1
    Join Date
    Mar 2012
    Posts
    7

    Loading xml file ion JavaScript to a div tag

    Hello

    I am stuggling with uploading an xml file in JavaScript onto my website. Would anybody be able to help?

    Thanks in advance
    Greenh

  2. #2
    Join Date
    Mar 2012
    Location
    Saint-Petersburg, Russia
    Posts
    97
    What kind of help you are seeking for? You forget to explain what technique of uploading you use and what server software is involved.

  3. #3
    Join Date
    Mar 2012
    Posts
    7
    Im using Dreamweaver and would like to bring the xml file in using JavaScript. Im not running it off of a server. Im new to all this :/

    Thanks

  4. #4
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    If you're trying to do what I think that you are trying to do then JavaScript is the way wrong way to go. Do you have PHP available?
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  5. #5
    Join Date
    Mar 2012
    Posts
    7
    I could do it in php, but im not too sure how

    Thanks

  6. #6
    Join Date
    Mar 2012
    Location
    Saint-Petersburg, Russia
    Posts
    97
    Shortly speaking you could not upload anything to server without receiving this stuff on server.

    I.e. if your server is "passive" and only contains static html web pages, you could not upload anything to it.

    You need not javascript. What you want is done via form element "input type=file" or "textarea" depending on whether you want to browse for your file or to paste it into text field. When form button "submit" is clicked the request is sent to "action" url of the form.

    Server should be able to properly receive this request, handle and store file.
    JavaScript is client-side scripting language and have nothing to do with it.

    So you need to set up your server to work with cgi, php, asp or other kind of scripts and then get back here to forum - I think the rest would not be very complicated. ;-)

  7. #7
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    In PHP it's way easy. But we'll need a wee bit more information.

    Where is the XHML? On the same file server as the PHP or elsewhere on the web? You'll have to get the file somehow. If it's elsewhere on the web things can get a little bit more involved.

    Do you want the whole XML file or just a part? And if it's just a part we'll need the match criteria.

    How big is the XML file? For small files things are way easy with DOMDocument. But for large ones you'll want to use the XML Parser.

    How do you want the XML transformed? We have to get it into HTML if we're going to embed it in HTML.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  8. #8
    Join Date
    Mar 2012
    Posts
    7
    Ive managed to do it in JavaScript :-) The only thing is in my xml file I have <Image>images/male.jpg</Image> This holds the location of the image wanting to be loaded however it doesnt load the image instead it just displays images.male.jpg.

    You have any idea why? Cheers for the advice etc :-)

  9. #9
    Join Date
    Mar 2012
    Location
    Saint-Petersburg, Russia
    Posts
    97
    Have you any troubles with reading and understanding what you've been told by colleagues?

    You could not, could not, could not upload file with only javascript to server. You could load the file into your browser and display it, but this have nothing to do with uploading to server.

  10. #10
    Join Date
    Mar 2009
    Posts
    452
    if you post your source code here maybe you can get your issue resolved.

  11. #11
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    Don't use JavaScript for this. PHP is 1) easier and 2) acrtually works. Lots of people, teeming masses, among them myself, don't use JavaScript. When we hit your page it won't work.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles