[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

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>

0
cheapstr
Asked:
cheapstr
1 Solution
 
str_kaniCommented:
<?xml-stylesheet type="text/xsl" href="Book1.xls.xsl"?>

Check, is this line right? href...
0
 
GrandSchtroumpfCommented:
Just read the w3school tutorial...
Interesting IE feature that i did not know.
But using IE-only features is not an option for me.

After some testing, i found out what makes the code break:  the XML cannot use any attributes.  That's very restrictive...

So, you should use this 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>
  <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>

Now, if you add an attribute to one of your columns, you'll see it disappear from the html page:
    <COL_2 myattribute="dummy">TEST 4</COL_2>

Since the XML seems to be generated, you'll either need to find a way to generate your XML without the attributes, or you'll need to process the XML to remove all attributes before using it with your html.
0
 
COBOLdinosaurCommented:
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&
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
GrandSchtroumpfCommented:
> 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.
0
 
COBOLdinosaurCommented:
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&
0
 
GrandSchtroumpfCommented:
> 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.
0
 
COBOLdinosaurCommented:
>>>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&
0
 
cheapstrAuthor Commented:
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.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now