Aus_Steph Posted April 28, 2006 Share Posted April 28, 2006 Im just learning XML, and cannot work out why this wont work when I try to embed the XML into HTML.Here are my codes:<xml id="steph"><family> <mother> <gender>Female</gender> <age>60</age> <name>Pam</name> </mother> <father> <gender>Male</gender> <age>61</age> <name>Geoff</name> </father> <child> <gender>Female</gender> <age>28</age> <name>Stephanie</name> </child></family></xml>And my HTML:<html><body><xml id="steph" src="steph.xml"></xml><table border="1" datasrc="#steph"><tr><td><span datafld="gender"></span></td><td><span datafld="age"></span></td><td><span datafld="name"></span></td></tr></table></body></html>Can Anyone tell me what I am doing wrong? I have just saved both into a folder on my desktop. Thanks! Link to comment Share on other sites More sharing options...
Little Goat Posted April 28, 2006 Share Posted April 28, 2006 try taking the <xml> tags out of the xml file.LG Link to comment Share on other sites More sharing options...
Aus_Steph Posted April 28, 2006 Author Share Posted April 28, 2006 That still wont work. When I open the XML file, I get the IE bar pop up at the top telling me it blocked content, is that normal? Link to comment Share on other sites More sharing options...
boen_robot Posted April 28, 2006 Share Posted April 28, 2006 Yes. It's normal to have such popo-up. And by the way, the XML prolog looks like this: <?xml version="1.0" ?> Delete the XML element (both the opening and closing tags) and replace it with that. Also, note that only IE is capable of running XML inside HTML with Data Islands."For the sake of completeness": <?xml version="1.0" ?><family><mother><gender>Female</gender><age>60</age><name>Pam</name></mother><father><gender>Male</gender><age>61</age><name>Geoff</name></father><child><gender>Female</gender><age>28</age><name>Stephanie</name></child></family> Link to comment Share on other sites More sharing options...
Kosher Kid Posted April 28, 2006 Share Posted April 28, 2006 even with the fix, the code doesn't work in ie. i've checked the microsoft msdn and the code appears to be right but it just won't display the data in the table rows.any clues? Link to comment Share on other sites More sharing options...
Aus_Steph Posted May 2, 2006 Author Share Posted May 2, 2006 Hmmm....yeh, it still wont work for me using that prefix. Link to comment Share on other sites More sharing options...
boen_robot Posted May 2, 2006 Share Posted May 2, 2006 I got it! The reason is inconsistent element names. A bad habbit you should try to avoid anyway. What do I mean? Well, each element in which you have the gender, age and name is different. Make it something universal and if you want to specify who is who, you can create a new element with this data. Here's a fixed kind of code: <?xml version="1.0" ?><family><member><type>mother</type><gender>Female</gender><age>60</age><name>Pam</name></member><member><type>father</type><gender>Male</gender><age>61</age><name>Geoff</name></member><member><type>child</type><gender>Female</gender><age>28</age><name>Stephanie</name></member></family> Link to comment Share on other sites More sharing options...
Kosher Kid Posted May 2, 2006 Share Posted May 2, 2006 boen:bingo...it works in ie6 but it won't in firefox because it doesn't support data islands.and you are absolutely right about good coding practices.if there were an icon for it, i'd give you a gold star! Link to comment Share on other sites More sharing options...
Aus_Steph Posted May 2, 2006 Author Share Posted May 2, 2006 Haha excellent. Thankyou!So each bit of info needs the same opening and closing tags as the next one in that table. Yeh?OK, so if XML data islands are only supported by IE, I should forget about using it in web design and stuff right? Sorry I am reallllllly clueless with some stuff! Link to comment Share on other sites More sharing options...
Little Goat Posted May 3, 2006 Share Posted May 3, 2006 well, there is omething you could do if you are at all familiar with java script:http://developer.mozilla.org/en/docs/Using...ands_in_Mozilla Link to comment Share on other sites More sharing options...
boen_robot Posted May 3, 2006 Share Posted May 3, 2006 So each bit of info needs the same opening and closing tags as the next one in that table. Yeh? Data Islands- yes. All other methods of extracting XML data (such as XSLT)- not necessary but reccomended. Just another reason for you to forget data islands and move on to the cooler stuff . Link to comment Share on other sites More sharing options...
Kosher Kid Posted May 3, 2006 Share Posted May 3, 2006 what do you mean by cooler stuff? Link to comment Share on other sites More sharing options...
boen_robot Posted May 3, 2006 Share Posted May 3, 2006 I mean every other method of extracting, using and manipulating XML data. XSLT for starters, but also server side scripting languages, XML DOM, other XML based languages (SVG, XLink, etc.) and maybe something else I've missed. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now