SitePoint Sponsor

User Tag List

Results 1 to 21 of 21

Thread: beginner, How does XML actually do something?

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    beginner, How does XML actually do something?

    I am begining to understand XML through the W3 schools tutorial. However, I don't understand how you get your code to actually do soemthing. Is there a very simple example of it actually being practical, not just the code being there? Like to you have to write the file that looks at the XML and from there defines what each tag or statement does? What is the called? XML seems very confusing to me.

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, what do you want it to do?

    XML is just a language format. To make XML do something, you need to use a schema, or build a schema of your own. XHTML, for example, is an XML schema, and it defines what <h1> is, what <b> is, what <div> is, etc.

    So you know, Mozilla Firefox's entire user interface is built using XML, CSS, and JS -- they call it "XUL".

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i didnt know that about FF.

    I actually have no idea what I want to do with it. I was offered a job in the business field to be an XML programmer for the summer, they said I could learn it and I agreed. However it is difficult for me to fully understand it without seeing it in action.

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm, "XML Programmer". I would start by learning XSLT, then learn DOM (which is a w3 standard, so its implementation is next to identical in PHP and JavaScript for example). Once you know DOM, you'll be able to easily work with XML, and XSLT can be very useful too.

    Other than that, I don't know what to suggest to you. "XML Programmer" seems strange, since XML is just "<whateveryouwant>yourvalue</whateveryouwant>", really.

  5. #5
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by someonewhois
    Hm, "XML Programmer". I would start by learning XSLT, then learn DOM (which is a w3 standard, so its implementation is next to identical in PHP and JavaScript for example). Once you know DOM, you'll be able to easily work with XML, and XSLT can be very useful too.

    Other than that, I don't know what to suggest to you. "XML Programmer" seems strange, since XML is just "<whateveryouwant>yourvalue</whateveryouwant>", really.
    I'd say the DOM should be learned first, so one understands how things work and how you can select the proper nodes. After that, XSLT and XPath make a lot more sense

  6. #6
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I suppose.

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well that wasnt the exact title. It was more like "we'd like someone who knows XML." so not knowing what XML was, i termed that "XML programmer" I guess it could be a variety of standards related to XML.

    BTW idont know PHP. is that a problem?

  8. #8
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nah. Most DOM tutorials will teach it in JavaScript. I'm not sure whether DOM is supported in .NET, but it's supported in PHP5 (which is pretty preliminary). That's the reason I reccomended learning XSLT, as XSLT is the exact same whether it's using the browser, PHP, ASP, etc.. Parsing an XML document with an XSLT document takes 4 lines in PHP5, and about 7 lines in PHP4. It's only a few lines in .NET as well, and the browser can do it automatically.

    There's thousands of standards related to XML, with more appearing every day. It'd be hard to guess which standards this job is expecting. You should ask them if there's anything specific.

  9. #9
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yea it was mentioned very quickly, i will get more details soon.

  10. #10
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by someonewhois
    Nah. Most DOM tutorials will teach it in JavaScript. I'm not sure whether DOM is supported in .NET, but it's supported in PHP5 (which is pretty preliminary).
    It's supported by .NET, as well as classic ASP (VBScript or JScript), Java, Python, and tons of other languages.
    Quote Originally Posted by someonewhois
    That's the reason I reccomended learning XSLT, as XSLT is the exact same whether it's using the browser, PHP, ASP, etc.. Parsing an XML document with an XSLT document takes 4 lines in PHP5, and about 7 lines in PHP4.
    Off Topic:

    7 lines in PHP4 unless your host doesn't like installing the proper libraries, then it's just warnings

  11. #11
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, cool. I was surprised to see how PHP5's DOMXML and JavaScript's DOM were basically identical. Only difference was that you use -> instead of . and you have dollar signs in front of the variables, but that's just a language construct thing.

    Yeah, well, what can you do.

  12. #12
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by someonewhois
    Oh, cool. I was surprised to see how PHP5's DOMXML and JavaScript's DOM were basically identical. Only difference was that you use -> instead of . and you have dollar signs in front of the variables, but that's just a language construct thing.
    Well since the DOM is a W3C standard, support for the same methods and properties should be expected (otherwise they're out of compliance ).

  13. #13
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That won't be the first. I suppose it is supposedly standardized. Cool. In that case, yeah, learn DOM first.

  14. #14
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    would it be safe to say that DOM is to XML what CSS is to HTML. DOM helps display and minipulate your XML code to display correctly?

  15. #15
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I quickly looked at the DOM tutorial on W3schools and am COMPLETELY lost.

    I do not know JS which is recommends knowing. but it also recommends learning XML first too. What should I do?

  16. #16
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by tns123j
    would it be safe to say that DOM is to XML what CSS is to HTML. DOM helps display and minipulate your XML code to display correctly?
    No, the DOM lets you manipulate elements in an XML (or HTML) document. So the DOM is to XML what the DOM is to HTML. CSS also works with XML by the way

  17. #17
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    does DOM do the same as CSS?

  18. #18
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by tns123j
    does DOM do the same as CSS?
    No. DOM affects behavior of elements while CSS affects the appearance of elements. There is a little bit of overlap but not much.

  19. #19
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is a basic example of a behavior DOM would affect?

  20. #20
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In can change the contents of an element:
    Code:
     <script type="text/javascript">window.onload = function()
     {
        document.getElementById('whatever').innerHTML = 'Hello World.';
     }
     </script>
     <div id="whatever">
     Hello?
     </div>
    Or get the contents:
    Code:
      <script type="text/javascript">window.onload = function()
      {
         alert(document.getElementById('whatever').innerHTML);
      }
      </script>
      <div id="whatever">
      Hello?
      </div>
    Plus tons fo other stuff.

  21. #21
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The document object model (DOM) is a standard way of representing and manipulating tree-based data in an object-oriented language.

    Each part of the tree is an 'element' which can have 'attributes' and 'child elements'. The DOM is a standard set of methods and properties which can manipulate these elements.

    The DOM is not particular to any language (such as ECMAScript, commonly known as JavaScript or JScript). It can be implemented in any object-oriented language.

    The DOM is also not particular to any document format (such as HTML, XHTML or XML). It can be applied to the use of any document that can be represented as a tree.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog · Twitter · Contact me
    Neon Javascript Framework Jokes

Bookmarks

Posting Permissions

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