Jump to content

Simple embedding problem with xml and html.


matthewst

Recommended Posts

I can get the example at Http://www.w3schools.com/xml/xml_data_island.asp to work just fine but when I try it with my own XML and HTML files it only displays a little white box.My XML:

  <?xml version="1.0" standalone="yes" ?> - <IncrepDataset xmlns="http://tempuri.org/IncrepDataset.xsd">- <Control>  <Control_ID>0</Control_ID>   <Name>DocViewer</Name>   <Filename>docviewer.dll</Filename>   <Icon>doc</Icon>   <IncrepLoadable>true</IncrepLoadable>   <Version>4.0.0.28546</Version>   <TStamp>2006-11-06T18:00:09.4160070-06:00</TStamp>   </Control>- <Control>  <Control_ID>-1</Control_ID>   <Name>RIDS</Name>   <Filename>ridswrapper.dll</Filename>   <Icon>tool</Icon>   <IncrepLoadable>true</IncrepLoadable>   <Version>4.0.0.28559</Version>   <TStamp>2006-11-06T18:00:32.8518090-06:00</TStamp>   </Control>- <Control>  <Control_ID>-2</Control_ID>   <Name>Explosives</Name>   <Filename>atfwrapper.dll</Filename>   <Icon>tool_bomb</Icon>   <IncrepLoadable>true</IncrepLoadable>   <Version>4.0.0.28559</Version>   <TStamp>2006-11-06T18:01:01.2952610-06:00</TStamp>   </Control>- <Control>  <Control_ID>-3</Control_ID>   <Name>ChecklistViewer.Bomb Response</Name>   <Filename>checklistwrapper.dll</Filename>   <Icon>tool_checklist</Icon>   <IncrepLoadable>false</IncrepLoadable>   <Version>4.0.0.28559</Version>   <TStamp>2006-11-06T18:01:21.5461976-06:00</TStamp>   </Control>- <DataType>  <Datatype_id>1</Datatype_id>   <name>String</name>   <description />   </DataType>- <DataType>  <Datatype_id>2</Datatype_id>   <name>Decimal</name>   <description />   </DataType>- <DataType>  <Datatype_id>3</Datatype_id>   <name>INT</name>   <description />   </DataType>- <DataType>  <Datatype_id>4</Datatype_id>   <name>Boolean</name>   <description />   </DataType>- <DataType>  <Datatype_id>5</Datatype_id>   <name>DateTime</name>   <description />   </DataType>- <IncidentReport>  <IncidentReport_ID>0</IncidentReport_ID>   <Name>new</Name>   <TStamp>2006-11-06T18:00:01.8344249-06:00</TStamp>   <ProfileName>Bomb Response</ProfileName>   <GUID>b2d785ca-98c2-47dd-9343-3714598d8f31</GUID>   <License>24CC0LFL5T0K5D3944700DLRWYNU3R</License>   <Version>4.0.0.26014</Version>   </IncidentReport>- <NodeKeyValue>  <NodeKeyValue_ID>0</NodeKeyValue_ID>   <Node_ID>0</Node_ID>   <Key>name</Key>   <Value>Start</Value>   <submission_id>0</submission_id>   <Datatype_id>1</Datatype_id>   <visible>1</visible>   <TStamp>2006-11-06T18:00:09.6163130-06:00</TStamp>   </NodeKeyValue>- <NodeKeyValue>  <NodeKeyValue_ID>-1</NodeKeyValue_ID>   <Node_ID>0</Node_ID>   <Key>address</Key>   <Value>C:\Documents and Settings\All Users\Application Data\DGI\CoBRA\4.0\Start\start.htm</Value>   <submission_id>0</submission_id>   <Datatype_id>1</Datatype_id>   <visible>1</visible>   <TStamp>2006-11-06T18:00:09.6163130-06:00</TStamp>   </NodeKeyValue>- <NodeKeyValue>  <NodeKeyValue_ID>-2</NodeKeyValue_ID>   <Node_ID>-1</Node_ID>   <Key>name</Key>   <Value>Emergency Response Procedures For Ordnance-Chem-IED-WMD</Value>   <submission_id>0</submission_id>   <Datatype_id>1</Datatype_id>   <visible>1</visible>   <TStamp>2006-11-06T18:00:39.4719223-06:00</TStamp>   </NodeKeyValue>- <NodeKeyValue>  <NodeKeyValue_ID>-3</NodeKeyValue_ID>   <Node_ID>-1</Node_ID>   <Key>address</Key>   <Value>C:\Documents and Settings\All Users\Application Data\DGI\CoBRA\4.0\docs\Emergency Response Procedures For Ordnance-Chem-IED-WMD.pdf</Value>   <submission_id>0</submission_id>   <Datatype_id>1</Datatype_id>   <visible>1</visible>   <TStamp>2006-11-06T18:00:39.4719223-06:00</TStamp>   </NodeKeyValue>- <IncidentLog>  <IncidentLog_ID>-4</IncidentLog_ID>   <TStamp>2006-11-06T18:00:34.2639663-06:00</TStamp>   <Entry>RIDS selected</Entry>   <AddedByUser>false</AddedByUser>   <submission_id>0</submission_id>   <Priority>Low</Priority>   </IncidentLog>- <IncidentLog>  <IncidentLog_ID>-5</IncidentLog_ID>   <TStamp>2006-11-06T18:00:39.4719223-06:00</TStamp>   <Entry>C:\Documents and Settings\All Users\Application Data\DGI\CoBRA\4.0\docs\Emergency Response Procedures For Ordnance-Chem-IED-WMD.pdf viewed</Entry>   <AddedByUser>false</AddedByUser>   <submission_id>0</submission_id>   <Priority>Low</Priority>   <Control_ID>0</Control_ID>   <Node_ID>-1</Node_ID>   </IncidentLog>- <IncidentLog>  <IncidentLog_ID>-13</IncidentLog_ID>   <TStamp>2006-11-06T18:01:26.9644749-06:00</TStamp>   <Entry>- 'IDENTIFY ON-SCENE COMMAND (OSC)/ COMMAND POST (CP) LOCATION.' checked</Entry>   <AddedByUser>false</AddedByUser>   <submission_id>0</submission_id>   <Priority>Low</Priority>   <Control_ID>-3</Control_ID>   </IncidentLog>- <IncidentLog>  <IncidentLog_ID>-14</IncidentLog_ID>   <TStamp>2006-11-06T18:01:38.6222841-06:00</TStamp>   <Entry>Incident Summary selected</Entry>   <AddedByUser>false</AddedByUser>   <submission_id>0</submission_id>   <Priority>Low</Priority>   </IncidentLog>  </IncrepDataset>

My HTML:

<html><body><xml id="log" src="CurrentLog.xml"></xml><table border="1" datasrc="#log"><tr><td><span datafld="AddedByUser"></span></td><td><span datafld="Priority"></span></td></tr></table></body></html>

Sorry about the length but I wanted to make sure anything that might be relevant was included.

Link to comment
Share on other sites

Maybe because you have dashes in your XML before your opening tags. That's only a browser's way of rendering raw XML. It's not how an XML file's source should look like. Remove all dashes ("-") and try again.

Link to comment
Share on other sites

I can't remove the dashes because the XML file is from a program log.I was able to get this to work, sort of.

<html><head><script type="text/javascript">var xmlDocfunction loadXML(){//load xml file// code for IEif (window.ActiveXObject)  {  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  xmlDoc.async=false;  xmlDoc.load("CurrentLog.xml");  getmessage()  }// code for Mozilla, etc.else if (document.implementation &&document.implementation.createDocument)  {  xmlDoc= document.implementation.createDocument("","",null);  xmlDoc.load("CurrentLog.xml");  xmlDoc.onload=getmessage  }else  {  alert('Your browser cannot handle this script');  }}function getmessage(){document.getElementById("IncidentLog_ID").innerHTML=xmlDoc.getElementsByTagName("IncidentLog_ID")[0].firstChild.nodeValuedocument.getElementById("TStamp").innerHTML=xmlDoc.getElementsByTagName("TStamp")[0].firstChild.nodeValuedocument.getElementById("Entry").innerHTML=xmlDoc.getElementsByTagName("Entry")[0].firstChild.nodeValue}</script></head><body onload="loadXML()" bgcolor="#FFFFFF"><p><font size="7"><b>COBRA Log</b></font><p><b>Log ID:</b><span id="IncidentLog_ID"></span><br/><b>Time Stamp:</b><span id="TStamp"></span><br/><b>Entry:</b><span id="Entry"></span></p></body></html> 

The problem is I can't get it to read beyond the first IncidentLog_ID, TStamp, and Entry. There are hundreds of ID's, TStamps, and Entrys in one of the real logs. How do I make the HTML read all of them?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...