Jump to content

XML Beginner Doesn't understand


moodey-aimee

Recommended Posts

hey all, i started to learn Xml on my course i'm doing and it's not sinking in my head. >_< I do not see the point in it.What would you use it for? Cause my course book all it seems to be is things like forms. for Price forms, Sales forms. I understand its a Data File Correct.Is there any way I can understand the coding easier? that will help it sink in my head better.these are the topics, in my book i'm learning

  1. Creating an XML Document - I think i understand the elements, thats like <FirstName>Alex</FirstName>
  2. Validating an XML Document - don't really understand this
  3. Formatting and Transforming XML Documents - I understand this a little. with the CSS and Html.
  4. Linking XML Documents - don't really Understand this
  5. Accessing XML Documents - don't really understand this

Also, in the book it tells me sometimes to open a XML file in a browser, well IE will not open it. So if anyone can help me that would be great, as i have to do a online test for this and i do not feel confident with it. >_<Thanks

Link to comment
Share on other sites

you can open up an xml document in IE and Firefox pretty nicely. Maybe you have some restrictions on IE that is not letting you open it. Try FF.The point of XML is to have a consistent data transfer language. It is typically used with web services. Say Flickr wants to expose some of its data to other applications. One way to provide its data to other application developers is through XML. It might look something like this, obviously with more data:

<photos>   <photo>	  <img_name>beach</img_name>   </photo>   <photo>	  <img_name>mountains</img_name>   </photo></photos>

Link to comment
Share on other sites

XML is a language for storing data. That's it.Because the data is written in plain text, it is easily transmitted over the web. For the same reason, XML documents are easily read and edited by human beings without the need for fancy software. But it doesn't HAVE to be transmitted over the web, and it doesn't HAVE to be read by human beings. These are just conveniences made possible by the text format.The purpose is to store data.When your book talks about forms, it is probably showing you ONE POSSIBLE application of XML. It might be showing you a way to use HTML forms to transmit data to a server that saves the data in XML format. It is possible to modify XML in a web browser using JavaScript, and that might also involve forms. But forms are just one possible tool for editing XML data. XML does not depend on forms.Other languages like XSLT can be used to transform XML into another language, often/usually HTML. Obviously, when you do that, the expectation is that you are preparing to transmit the data to a browser. That's where the CSS comes in.If you have more specific questions, we can try to answer them.

Link to comment
Share on other sites

DRAT...Everytime I try and copy something out of one of your posts, I wind up REPOSTING the whole thing! Ok, I'm gonna quit doing that!@

XML is a language for storing data. That's it.Because the data is written in plain text, it is easily transmitted over the web.
Let me see if I understand a little. If I have a web form for ordering pizzas, for example, There will be text describing the type of crust, the toppings, and there will be numbers -- like how many I want, and the price,etc. But those numbers will also be in a text format. So, I wouldn't really need XML to transmit this to the server, would I? But the web form may also contain images -- like a picture of my store, or a picture of a pizza or something; so, I would use XML as the mechanism to transmit just the data back to the server, without the pictures? Would that be a valid use of XML?
Link to comment
Share on other sites

I think it would depend on what you intend to do with the data when it reaches your server. If you plan to read it in XML format and keep it that way (instead of turning it into a bunch of arrays or objects or something) then XML might be a good solution. It might be the best solution if you plan to save the data as an XML file.Length is often a consideration when making the choice. By its very nature, XML is a verbose format. If we're talking less than 2-3K, this is probably not a big deal.Probably the most efficient way to transmit data is in JSON format. Basically, stringified javascript objects (and arrays) that many serverside languages can reconstruct as native objects. To take your pizza example, if the goal was to send it to your server and have the server print out an order ticket, XML might be overkill. Likewise, if the plan is to send data by XML and then parse it out for storage in a relational database.Even simpler might be the normal form mechanism. Is there a reason you are exploring alternatives? Or are you asking theoretical questions to decide when XML is a useful format?In either case, there would be no need to send your server any images or text that you don't want to send. That is entirely within your control.

Link to comment
Share on other sites

I think it would depend on what you intend to do with the data when it reaches your server. If you plan to read it in XML format and keep it that way (instead of turning it into a bunch of arrays or objects or something) then XML might be a good solution. It might be the best solution if you plan to save the data as an XML file.Length is often a consideration when making the choice. By its very nature, XML is a verbose format. If we're talking less than 2-3K, this is probably not a big deal.Probably the most efficient way to transmit data is in JSON format. Basically, stringified javascript objects (and arrays) that many serverside languages can reconstruct as native objects. To take your pizza example, if the goal was to send it to your server and have the server print out an order ticket, XML might be overkill. Likewise, if the plan is to send data by XML and then parse it out for storage in a relational database.Even simpler might be the normal form mechanism. Is there a reason you are exploring alternatives? Or are you asking theoretical questions to decide when XML is a useful format?In either case, there would be no need to send your server any images or text that you don't want to send. That is entirely within your control.
Link to comment
Share on other sites

yes, just trying to get a handle on when to use xml, and how it interfaces with html. I understand the advantage is that it stores everything in text; but it seems to me that all the relavent info. that you want to store from an html form is already in text anyway --- > so, having a little bit o trouble getting the concept... But it's starting to kind of hit me that perhaps xml has other uses besides an interim between html on a client and a database on the server... On the other hand, if it truly is mainly used for that purpose, then I'm not getting it yet.I think I'll peruse your earlier posts a little more; Sometimes things sink in after 3 or 4 readings! :)

Link to comment
Share on other sites

I think you're assuming a stronger relationship between XML and HTML than there really is. HTML presents information in a way that is convenient for readers to understand. XML stores data in a way that is convenient for adding, removing, and changing.Consider this analogy. It's not exact, but it might help.An HTML document is like a book you read for pleasure. An XML document is more like a dictionary or phone book.XML makes a poor interim between HTML and a database. A more compact model like JSON, or just a POST/GET request, is usually much more efficient. When thinking about XML, think about storage first.

Link to comment
Share on other sites

So in this whole "web-thing scenario" -- a client requests something from a server, a server sends a form to the client, the client fills some stuff in and sends it back to the server, the server validates it and if it's incorrect sends it back to the client, the client corrects it and sends it back to the server, and the server revalidates it and then posts it to the database -- WHERE -- if Anywhere -- does XML come in?If I'm understanding you correctly, my thinking is that XML is not really something that is needed in the scenario described above. But if I want to transfer my data from say, one company to another or, maybe if I'm going between, say SAP and ORACLE then I might want to use XML... Am I starting to get on the right track now?

Link to comment
Share on other sites

In the flowchart you described, you are correct. XML is not required.XML can be used to transfer data between one database and another. If your DB is sophisticated enough, it might even be able to export multiple tables into one document, and also extract multiple tables from that document.Other export/import techniques might be more reliable.As I've said, XML is primarily a storage mechanism. It is an alternative to a relational database that is useful in some situations, but not all situations. It is especially useful if you want to use XSLT to transform the XML into an HTML document on the fly. I personally use it in some situations where I import an XML document into a browser using AJAX. The user edits the XML document using DOM methods. When the user is finished, AJAX sends the document back to the server and immediately saves it as a file. This streamlines the server-client relationship.As a structure for transmitting data, XML is also the format for RSS, and I suspect that in the future this may become true for other popular kinds of data as well. I should have mentioned this earlier in the thread.

Link to comment
Share on other sites

Thanks much, DD for all your very well - articulated answers. I'm trying to figure where to prioritize XML in the list of things I need to study. I'm trying to get to sharepoint development, so I'm trying to wade thru what I consider to be the prerequisites.For me, so far, I'm thinking, in this order, HTML, CSS, Javascript/DOM/Ajax, then Visual Studio, VB_SCRIPT and/or C#, ASP.Net, maybe PHP, sql_server. So now thinking XML should probably be at the end of this list. ( There's also something, I've learned called Silverlight, which I think comes probably after, or along size ASP.NET). So, ALL THIS -- -AND THEN Sharepoint! OY! ...but, like getting to the top of Everest, it still boils down to one step at a time...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...