...

Changing XML > XHTML via PHP

Erich
04-25-2003, 08:29 PM
Ive asked a bunch of people for help on this, including brother cake (thank you :)), but unfortunatly I find myself STILL confused, so please bare with me. Note, I visit and read w3schools as often as i can.

First things first, im having trouble grasping these concepts: DOM, DTD, Schema, Parser, Node, SGML. I seem to be oversaturated with information after expanding myself from html/css. Im not really looking for a tutorial on the concepts, but just some form of base knowledge i can work off of so that when its brought up I nkow whats being talked about.

Secondly, should i use XML as a database backend for a website (fyi - its an artists tour database), and then use PHP to extract information from it? Or should i approach it differently? Im hoping to be able to set up a template document, and depending on the url id, bring up a different section of a main tour.xml file. example:

theres one page for a list of tourdates, and by default its blank. if the user points the browser to say tour/?id=2002, or tour.php?id=2002, it will pull that particular information from the XML document as per how I want it. same with a show.php?id=20030319 call. Im looking for it as a way to decrease the amount of documents on the site, and increase the organization and ease of my updating it, as i could just update one file and it would generate correctly if called. It would also allow me to completely change site format with no problem transfering data.

Since that in and of itself is all static data, would the prefered backend change if i were to want it to be client side manipulatable *unties tongue*, as in making it searchable, or making the user be able to generate statistics? If that particular level of functionality were to be added, would I need to use anything different?

Now, as an added crutch, I have basicly no knowledge of PHP beyond maybe a Hello World statement. All i have is the basic idea of what i want for the website, and nowhere to go from there.

thanks again for the time to look at this, and sorry for my increased persistance :)

~ Erich w/ an h

Alex Vincent
04-25-2003, 08:46 PM
Ack, too much at once.

Erich, you're asking like 4 different questions in this thread. I can help you with the DOM and Node bits (Node is part of DOM), and with DTD as that's a pretty basic part of XML.

Have you ever used DOM Inspector for Mozilla or Netscape browsers? You can learn a lot about the DOM from tinkering around with it.

Erich
04-25-2003, 09:07 PM
Originally posted by Alex Vincent
Ack, too much at once.

Erich, you're asking like 4 different questions in this thread. I can help you with the DOM and Node bits (Node is part of DOM), and with DTD as that's a pretty basic part of XML.

Have you ever used DOM Inspector for Mozilla or Netscape browsers? You can learn a lot about the DOM from tinkering around with it.

sorry, learning makes me anxious :p. But thanks for the reply.

I have never used DOM Inspector, no. Where can I go about using it, since i dont own any NS browsers.

Alex Vincent
04-26-2003, 01:17 AM
I'd recommend downloading Mozilla 1.3 (the zip version; installers cause trouble for new people), and then unzip it into a new directory. DOM Inspector is available from the Tools, Web Development menu. You can also inspect a document from Mozilla Navigator with the key combination Ctrl+Shift+I.

Erich
04-26-2003, 03:48 AM
thanks muchly :)

hopefuly this and w3schools can get me a little less confused on the matter.

now, can anyone tell me if my site proposal is fesable? hope im not being a pest.

Erich
04-26-2003, 05:18 AM
ok, lets see if i have the basic idea of this...

A parser is a self contained program that, when loaded with an xml document, breaks the document up into its different components. its then represented as a tree structure, or DOM, composed of different Nodes. each Node represents a different part of the document such as element, tag, and attribute. Information can be taken from the document by accessing the DOM using whatever language you wish, and presenting it whichever way you want.

Do i have a basic grasp of this?

edit: and dtd/schema is a way to lay out a basic structure of your xml document beforehand, like a set of rules. i think ive got that down now.

Alex Vincent
04-27-2003, 09:37 PM
So far, so good. :) Keep going.

bluephoenix
05-27-2003, 02:58 AM
Hey, Eric...

Of course your idea is feasable; it may sound cliché but I think it's important to approach any situation with a can-do attitude, but more on that in a bit. I'll try to touch on some of your other questions first.

A markup language is a collection of directions and special symbols that are inserted throughout a document. These directions can identify special sections of the document and further define the information's background and meaning.

In the 1970's IBM needed a markup language to use in their large volumes of technical documents to help them keep track of the information and keep up to date with revisions and changes. They set down to creating the Standard Generalized Markup Language (SGML). The specification for SGML is over 500 pages! The Organization for International Standards (ISO) saw great value to the project and has acknowledged SGML as a universal standard.

XML is a set of rules based on the SGML standard that oversee how new languages should be written. A markup langauge conforming to XML is known as an XML application.

Each XML application has a Document Type Defenition, commonly refered to as a DTD. The DTD is the basic "blue-print" of an application. A document marked up with a particular application can be shared and anyone can see how all its pieces fit together by refering to the DTD.

Since an application's markup identifies the various pieces of information in a document, a computer program can accept, parse (separate into different pieces) and understand the data. It can then display the information any way that is convenient for the viewer. The componant of the program that reviews the document and breaks it into it's various pieces is called a Parser.

Sections of information that are nested within one can be looked at as having a parental/offspring/sibling relationship to the other information around it. Oftentimes (or at least it should!) if the relationships these elements share are mapped out it would resemble an inverted family tree. Each point where another "branch" stems from is known as a node.

For example, in an HTML document <HTML> is the root node; all other branches stem from this node (all other elements are nested within it). <HTML> has two children nodes, <HEAD> and <BODY>. <HEAD> and <BODY> are sibling nodes because they share the same parent node, <HTML>.

The Document Object Model (DOM) is a way of thinking of a document not as a flat, solid document, but rather as a whole made up of several smaller parts (much like a building is constructed of bricks). You can use the DOM idea and the idea of relationships between elements (nodes) to idenify specific information within the document.

Going back to the HTML document example, I can find it's title by starting at the root node, <HTML> and trace the "family tree" until I get to the information identified with the <TITLE> tag.

HTML -> HEAD -> TITLE -> "Title of HTML Document"

I highly recomend the book XML Black Book published by Coriolis. I purchased the 2nd edition at a local computer store on the clearance rack for US$19.99 ($49.99 was the listing price).There are several tutorials available on the internet as well. And, you're always welcome to check out my yahoogroup, CyberDev Digest (http://groups.yahoo.com/group/cyberdevdigest), participate in our Essential XML course, pose your questions about PHP and other stuff.

Now back to the XML/PHP solution for your site. Of course it's possible! A few months ago I used a similar solution for the website I maintain for work.

I needed to keep track of various ATM locations within the Sharenet ATM network. I also wanted to be able to display the information in different forms, such as populating menus with the information, being able to extract the information for those ATMs only within a specified location, generate report of all ATM locations, etc. My server didn't support MySQL so I decided to devise my own XML application to create a flat database with the information.

I was able to use PHP to scan through the XML file and to extract and display to desired entries. The end result is currently at http://www.acmgfcu.org/temp/findatm.php
. If you'd like, you can email me at tboronczyk@acmgfcu.org and I can email you the source files.

Depending on the amount of information you'll be maintaing I think that an XML/PHP solution would be perfectly legitimate for you. You really wouldn't need to change how your data is marked with XML to add search capabilities or statistics, you'd simply establish a suitable application for defining the data and construct various php scripts to work with it.

I hope I've been a little help. If you have any questions you can email me at the address above. I don't claim to be an expert but I know a bit and I'm willing to help if I can. Best of luck!

-Tim



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum