Jump to content

Xml Is Confusing!


eTianbun

Recommended Posts

Thank God you are here; i have been waiting for a reply to my question. Ok! Is it that xml, is just like html, just that the tags are created by the author and the tag does'nt display anything, because the tags are used to describe the information it hold, while html displays it? can xml be used to create a website when it is styled with stylesheet? Ex: mysite.xml just like mysite.html?

Link to comment
Share on other sites

XML syntax is similar to HTML, but XML has nothing to do with HTML. XML is kind of like a plain text file: you put data there in text format. The difference is that it's stored in a tree form. You don't use XML to make websites, you use XML to pass information to an application. Given your knowledge, you probably won't be needing XML.

Link to comment
Share on other sites

You build an application (In C++, PHP, Java... etc. that is prepared to look for specific tags that you have defined for your XML document. An XML file can be styled with XSL or CSS, but this is only so that you can present the data inside the XML file in a format that is easier to read. (For example, when a user views an RSS feed) You should not use XML to make websites.

Link to comment
Share on other sites

Ok, am begining to get it. Look @ the example below!HTML:

<p> This is a paragraph with <b> bold </b> text</p><!-display a paragraph and a bold text--->

XML:

<paragraph> This is a paragraph with <bold> bold </bold> text</paragraph>

in the first example, it says: "display a paragraph, with "bold " as bold text". Is it that in the XML, it is saying:" everything between

<paragraph>and</paragraph>

, is a paragraph"? Is it that the tags, is just a way to label the data it carries?

Link to comment
Share on other sites

What you're describing is actually the proper usage of HTML. HTML is used to describe content, XML is used to store data.Here's an example of proper usage of XML:

<kitchen>  <furniture id="1">	<name>Table</name>	<width>1.2m</width>	<length>1.4m</length>	<height>0.8m</height>  </furniture>  <furniture id="2">	<name>Chair</name>	<width>0.6m</width>	<length>0.6m</length>	<height>1.12m</height>  </furniture></kitchen>

Link to comment
Share on other sites

hmmm! This xml is confusing, but the syntax is easy. Now, how do you describe your example? is it that you are saying "everything between the parent tag (<kitchen>), is about kitchen"? How do you explain it? Thanks for all your help so far, i realy appreciate!

Link to comment
Share on other sites

You can design the program to interpret the XML however you like. XML is made so that the stored data can be understood by humans so that people can make the files themselves instead of relying on an application to generate the data file. You can easily tell that I'm storing data about furniture in a kitchen. A PHP program can use the data to display the furniture information on a website, or another program could use it to reserve space in a kitchen design for the furniture. XML is used by programming languages to use and store data. The data could be anything, it depends on the programmer or software engineer that's making the project. Here's a simple example of using my kitchen XML in a PHP program:

<?phpheader('Content-type: text/plain');$document = new DOMDocument();$document->load('kitchen.xml'); $furniture = $document->getElementsByTagName('furniture');echo ' ==== Kitchen data ==== ';foreach($furniture as $item) {  echo ' == ' . $item->getElementsByTagName('name')->item(0) . " ==\n";  echo 'Width: ' . $item->getElementsByTagName('width')->item(0) . "\n";  echo 'Length: ' . $item->getElementsByTagName('length')->item(0) . "\n";  echo 'Height: ' . $item->getElementsByTagName('height')->item(0) . "\n";}?>

Link to comment
Share on other sites

think of kitchen.xml as being the database,<kitchen> will be the table <furniture> will be the record row everything between <furniture> ...</furniture> will be fields containing data related to every record row you can retrieve this record row data, and then by using the element container with a specific class that this retrieved data is place into, style it as required.

Link to comment
Share on other sites

Thanks dsonesuk! But to be sincere, i'm not familiar with database. Is there any other way to describe it? Can i say: <kitchen>, is a root directory, containing data, related to kitchen, while <furniture>, is sub-directory, containing data (infomation) about furniture? thanks guys!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...