Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
07-08-2009, 09:19 PM #1
- Join Date
- Feb 2009
- Thanked 0 Times in 0 Posts
My first (very simple) attempt at learning XML
Hello! I am very interested in learning how to create XML data using XSLT, so after reviewing some of the information, I took a shot at my first XML dataset plus a corresponding schema. That being said, I am a total newb to XML and am sure there is something wrong with this. Before I do that, here was what I was trying to accomplish - something simple to start.
I wanted to create a script on a site that contained recent news items from a ficticious company. These items would be written by whomever runs the site. Since these would be updated frequently, I wanted to create an easy way to dynamically update the information while only coding the html once. That is why I want to use XML for it. At this point, the only way the information can get updated is through editing the xml file itself. Once I get better at it, I would like to create a form that will update the xml data in the xml file.
I realize there are already all sorts of things out there that create this functionality and that is fine, but remember, I am trying to learn XML here, so this is where I started. Here is my code:
The XML file:
<?xml version="1.0"?> <news_item xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mysite.com news_item.xsd"> <date>07.08.09</date> <teaser>Just some text here that is a teaser of the full news item</teaser> <full_text>http://www.someurl.com/</full_text> </news_item>
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> <xs:element name="news_item"> <xs:simpleType> <xs:sequence> <xs:element name="date" type="xs:string"/> <xs:element name="teaser" type="xs:string"/> <xs:element name="full_text" type="xs:string/> </xs:sequence> </xs:simpleType> </xs:element> </xs:schema>
Basically, what I need to know is 1.) If the syntax and structure is correct, and 2.) In the state that it is in now, can I start using code in my html to draw this info into the page and display it without any errors? Any tips on where to find simple code to allow me to simply pull this information into a div in my html page? Thanks.
I appreciate any feedback. Thanks!
Last edited by shelzmike; 07-08-2009 at 09:21 PM.