• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • 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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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