Jump to content

Keywords categories?


emeraude

Recommended Posts

Hello everyone! I'm brand new to XML and I haven't actually tried to write anything in it yet, but I'm looking for something that will work best for the site I have in mind. See, I want to make some kind of 'encyclopedia' with all sorts of info in it, and that information needs to be linked to a keyword/category, so that I can display those entries by category. Is it possible to do such a thing with XML? Can I do something like <keyword>example</keyword> and then do something along the lines of: if keyword is 'example', display it...?I have the feeling that it's probably easier to reach this goal with PHP, but I just can't seem to figure out how to work with that. I have experience in XHTML & CSS and a little ActionScript 2.0, so please help me in dummy language! :) Also, one more thing:From the tutorials on this website I understood pretty much all of it, but... what exactly is 'parsing'...? :)

Link to comment
Share on other sites

You're pretty close to what you think. It would be easier with an SQL database, most notably MySQL. And yes, MySQL would be easiest to use on PHP.This can be done in XML too of course, but not with the same ease really. As articles grow, you'll need more then just a category, which is where XML starts to get hard.As for "parsing". Programs and languages that read XML don't "see" what you see in the file. They call a special application, called an "XML parser" that turns it into a form they can understand. So, "parsing" is the process of turning XML files into whatever, non-text representation the application can read. Most often, this is a DOM tree, as described by the XML DOM tutorial, but it's not the only possible representation. In PHP for example, not only you have the DOM set of classes, but also the XMLReader and the SimpleXML, which read the XML in their own fashion.

Link to comment
Share on other sites

Thanks for the explanation about the parsing! I think I'll just try to follow the tutorial blindly to set it up... Would you happen to know what codes I should use to achieve that it's displayed per category in XML? Or could you direct me to any tutorials explaining something along these lines? Thanks!

Link to comment
Share on other sites

Thanks for the explanation about the parsing! I think I'll just try to follow the tutorial blindly to set it up... Would you happen to know what codes I should use to achieve that it's displayed per category in XML? Or could you direct me to any tutorials explaining something along these lines? Thanks!
Well, the mentioned XML DOM is one tutorial for that. XPath is just a must. It's also used in PHP's DOM, as well as other languages that deal with XML documents, mostly XSLT. XSLT can be used to do all the "combining" and "adjustings" to the XML from it's storage, to what you will show the client.A typical scenario for showing articles in categories with XML would include generating a "site map" with PHP as an XML file, and then using XSLT to get information out of each file corresponding to the right category. Once you start having lots of articles however, you'll see things may start to get non efficient. That's the time where you might want to learn about XMLReader, but until you undestand the whole process, I suggest you stick with "plain XML file, transformed one time with one plain XSLT file" strategy.The order in which I suggest you go is: XPath, XSLT (, PHP SimpleXML), PHP DOM (starting from the DOMXPath class), PHP XMLReader. There is a tutorial for all of those on W3Schools except XMLReader (instead, there is for Expath, but XMLReader is just better), but then again, if you go that far, than using the reference on php.net to teach yourself should be no problem.BTW, I know you haven't asked this yet, but you will, so I'll save you the trouble - "Serialization" is the opposite of parsing. The process of turning an application readable form (like a DOM tree) into an XML text.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...