Link to home
Start Free TrialLog in
Avatar of cheapstr
cheapstr

asked on

Reading XML Data

I am trying to display some XML data on a web page using HTML. For some reason I cannot get the XML data to display? Can anyone help?

Here is my xml file (Temp.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<?xml-stylesheet type="text/xsl" href="Book1.xls.xsl"?>
<!-- This XML file is generated by RustemSoft XML Converter Evaluation version -->
<table name="Sheet1$">
  <Sheet1>
    <COL_1>TEST1</COL_1>
    <COL_2>TEST 4</COL_2>
    <COL_3>TEST 7</COL_3>
  </Sheet1>
  <Sheet1>
    <COL_1>TEST2</COL_1>
    <COL_2>TEST 5</COL_2>
    <COL_3>TEST 8</COL_3>
  </Sheet1>
  <Sheet1>
    <COL_1>TEST3</COL_1>
    <COL_2>TEST 6</COL_2>
    <COL_3>TEST 9</COL_3>
  </Sheet1>
</table>

////////////////////////////////////
Here is my HTML file:
<html>
<body>

<xml src="Temp.xml" id="xmldso" async="false"></xml>

<br />ONE:
<span datasrc="#xmldso" datafld="COL_1"></span>
<br />TWO:
<span datasrc="#xmldso" datafld="COL_2"></span>
<br />THREE:
<span datasrc="#xmldso" datafld="COL_3"></span>

</body>
</html>

Avatar of Kani Str
Kani Str
Flag of India image

<?xml-stylesheet type="text/xsl" href="Book1.xls.xsl"?>

Check, is this line right? href...
ASKER CERTIFIED SOLUTION
Avatar of GrandSchtroumpf
GrandSchtroumpf

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you have to have the attribute in the data on the page, then make them child nodes.  You will have to change the generation, but yu should be able to keep the relationship, and then jut hide the node with the attribute in it so it does not render the attribute value as plain text.

GS, don't be surprisd by the weak support for xml by M$.  It is only in their interest to support xml where they can use there own standards.  They see no profit in supporting open source standards, so they don't.  On the web side of it they have made a mockery out ot XHTML1.1, by insisting on a bunch in stuff, and then not supporting the standard because it would leave .NET as an orphan.

Cd&
Avatar of GrandSchtroumpf
GrandSchtroumpf

> GS, don't be surprisd by the weak support for xml by M$.
I'm never surprised of anything that comes from M$.
I'm just surprised w3schools does not mention that the xml cannot contain any attributes.  They make it sound it works with any valid xml document.
There is no reason the attibute should not work correctly except that the XHTML1.0 and 1.1 specification is impossibel to implement and require DOM 3 to do it right.  The result is that we have different impplementations of methods that work with the attributes and the stylesheet object.  XHTML2.0 cleans it up but we are 18 to 24 months before we see browsers that implement XHTML2, CSS3 and Dom 3 in the meantime we are stuck with partial implementations, lame standards support, an M$ slopcode to support .NET.

Cd&
> There is no reason the attibute should not work correctly
I agree with that, but there is no reason for it to work either.
The supported xml format depends on the implementation specifications.
However, i don't think it would have been hard for them to add support for the attribute.

Xml is just a generic format.
AKAIK, in this case the xml source has nothing to do with xhtml.
>>>AKAIK, in this case the xml source has nothing to do with xhtml.

Absolutely correct.  In fact if you added an xhtml doctype IE would still render in quirks mode because that is only way it can actually reference the xml tag.

Cd&
Avatar of cheapstr

ASKER

After some testing, i found out what makes the code break:  the XML cannot use any attributes.  That's very restrictive...
-That did it. I used a trial version of XML Creater to convert a sample EXCEL sheet to xml and it created the <table name="Sheet1$"> automatically.
Thanks.