J
jeffc
I'm just learning XML and am reading "Inside XML" by Holzner. He gives an
early XML example file.
<?xml version = "1.0" encoding="UTF-8"?>
<DOCUMENT>
<GREETING>
Hello From XML
</GREETING>
<MESSAGE>
Welcome to the wild and wolly world of XML.
</MESSAGE>
</DOCUMENT>
He explains that when opened with IE, it will simply display the contents
(which it does.) Then he gives a second example, which he says will read
from that file when a button is pressed. The following code is supposed to
"execute" when opened with IE. But, all it does is display the formatted
text, just like the first example. Anyone know what's going on? (By the
way, I altered one of the lines. The tag "INPUT" was not valid, so I put a
"/" at the end of that tag. I'm assuming this was a typo in the book,
right?)
<HTML>
<HEAD>
<TITLE>
Finding Element Values in an XML Document
</TITLE>
<XML ID="firstXML" SRC="greeting.xml"> </XML>
<SCRIPT LANGUAGE="JavaScript">
function getData()
{
xmldoc = document.all("firstXML").XMLDocument;
nodeDoc = xmldoc.documentElement;
nodeGreeting = nodeDoc.firstChild;
outputMessage = "Greeting: " + nodeGreeting.firstChild.nodeValue;
message.innerHTML = outputMessage;
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<H1>
Finding Element Values in an XML Document
</H1>
<DIV ID="message"> </DIV>
<INPUT TYPE="BUTTON" VALUE="Get The Greeting" ONCLICK="getData()"/>
</CENTER>
</BODY>
</HTML>
early XML example file.
<?xml version = "1.0" encoding="UTF-8"?>
<DOCUMENT>
<GREETING>
Hello From XML
</GREETING>
<MESSAGE>
Welcome to the wild and wolly world of XML.
</MESSAGE>
</DOCUMENT>
He explains that when opened with IE, it will simply display the contents
(which it does.) Then he gives a second example, which he says will read
from that file when a button is pressed. The following code is supposed to
"execute" when opened with IE. But, all it does is display the formatted
text, just like the first example. Anyone know what's going on? (By the
way, I altered one of the lines. The tag "INPUT" was not valid, so I put a
"/" at the end of that tag. I'm assuming this was a typo in the book,
right?)
<HTML>
<HEAD>
<TITLE>
Finding Element Values in an XML Document
</TITLE>
<XML ID="firstXML" SRC="greeting.xml"> </XML>
<SCRIPT LANGUAGE="JavaScript">
function getData()
{
xmldoc = document.all("firstXML").XMLDocument;
nodeDoc = xmldoc.documentElement;
nodeGreeting = nodeDoc.firstChild;
outputMessage = "Greeting: " + nodeGreeting.firstChild.nodeValue;
message.innerHTML = outputMessage;
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<H1>
Finding Element Values in an XML Document
</H1>
<DIV ID="message"> </DIV>
<INPUT TYPE="BUTTON" VALUE="Get The Greeting" ONCLICK="getData()"/>
</CENTER>
</BODY>
</HTML>