?
Solved

XML DataBind Not working

Posted on 2006-04-18
9
Medium Priority
?
293 Views
Last Modified: 2010-05-18
Hi,

I have followed steps in multiple tutorials to data bind my XML data to a HTML table, but it does not display any records.

Does any body know of why this may be?

Thanks in advance

Andrew
0
Comment
Question by:REA_ANDREW
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 9

Expert Comment

by:smaccari
ID: 16477103
Maybe your code could help us find your problem.
0
 
LVL 6

Expert Comment

by:nabsol
ID: 16477106
Hi

Hope this helps!

http://www.devpapers.com/article/269

By Nab
0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 16477110
ok here is the code for the page which displays and adds to the XML file

<html>

<head>
<script language="javascript">
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(title,link,body) {
      document.getElementById("loading").style.display='';
    http.open('get', 'xmlSave.asp?title='+title+'&link='+link+'&body='+body);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        //if(response.indexOf('|' != -1)) {
        //    update = response.split('|');
        //    document.getElementById(update[0]).innerHTML = update[1];
        //}
        document.getElementById("loading").style.display='none';
        document.getElementById("foo").innerHTML = response;
       
    }
}

</script>
<title>New Page 1</title>
</head>

<body>

<div id="news" style="float:right;">
<xml id="NewsIT" src="newsfeed.xml" ASYNC="false"></xml>

<table border="1" >

<thead>
<tr><th>Date</th><th>Title</th><th>Link</th></tr>
</thead>

<tfoot>
<tr><th colspan="3">This is my BLOG</th></tr>
</tfoot>

<tr>
<td><span datasrc="#NewsIT" datafld="Date"></span></td>
<td><span datasrc="#NewsIT" datafld="Title"></span></td>
<td><span datasrc="#NewsIT" datafld="Link"></span></td>
</tr>
<tr>
<td colspan="3"><span datasrc="#NewsIT" datafld="Body"></span></td>
</tr>

</table>
  <div id="foo">
  </div>
</div>
<form method="POST" name="form1" action="">
  <p>Title<br>
  <input type="text" name="T1" size="20"></p>
  <p>Link<br>
  <input type="text" name="T2" size="44"></p>
  <p>Body<br>
  <textarea rows="7" name="S1" cols="37"></textarea></p>
 <a href="javascript:sndReq(document.form1.T1.value,document.form1.T2.value,document.form1.S1.value)">Add News Item</a><div id="loading" style="display:none;">....loading, please wait</div>
</form>

</body>

</html>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Author Comment

by:REA_ANDREW
ID: 16477116
It adds to the XML file no problem. It is the retrieving of the data that is not working
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 16477129
Hello REA_ANDREW,

put datasrc into you table tag, i.e.
<table border="1" datasrc="#NewsIT" id="tbl">

and remove it from your span tags

check newsfeed.xml what's in and how it is loaded...

HTH

I
0
 
LVL 20

Author Comment

by:REA_ANDREW
ID: 16477141
I have amened as you said.  Although still nothing is showing. Here is my XML file, there may be an error in there as I have never worked with it before

http://www.nwcms.co.uk/andy/xml/newsfeed.xml
0
 
LVL 6

Accepted Solution

by:
nabsol earned 1000 total points
ID: 16477164
Hi

This is how binding works:

< ?xml version="1.0" ?>
<!--  Filename - contact.xml  -->
<contact>
 <party>
  <name>Chief Programmabilities</name>
  <email>bgates@programmabilities.com</email>
  <organization>Programmabilities</organization>
  <address>1 Programmabilities Complex</address>
  <phone>1-661-716-2564 x7678</phone>
  <im>bgates@programmabilities.com</im>
  <url>http://programmabilities.com/</url>
  <p xmlns="http://programmabilties.com/contact.php">
    Contact</p>
 </party>
</contact>



<html><header><title>Contact</title></header><body>
  <!-- Contact module -->
  <xml id="Contact"
         src="http://programmabilities.com/xml/contact.xml"/>
  <table cellpadding="0" cellspacing="0" border="0"
         datasrc="#Contact">
   <tr>
    <td><strong>Name</strong>:</td>
    <td><div dataFld="name"/></td>
   </tr>
   <tr>
    <td><strong>Address</strong>:</td>
    <td><div dataFld="address"/></td>
   </tr>
   <tr>
    <td><strong>Mail</strong>:</td>
    <td><div dataFld="email"/>
    </td>
   </tr>
   <tr>
    <td><strong>IM</strong>:</td>
    <td><div dataFld="im"/></td>
   </tr>
   <tr>
    <td><strong>URL</strong>:</td>
    <td><div dataFld="url"/></td>
   </tr>
  </table>
  <!-- END Contact module -->
</body></html>


But in your case I think problem is that you have one tag field with changing id.

Nab
0
 
LVL 22

Assisted Solution

by:Ivo Stoykov
Ivo Stoykov earned 1000 total points
ID: 16477207
Hi REA_ANDREW,

you have to put as a datafld the name of the fields in you XML file, i.e.

<span datafld="name">&nbsp</span>
this way the span will extract and show the name from your XML file on each table row...

regards

I
0
 
LVL 6

Expert Comment

by:nabsol
ID: 16477235
Hi

I think to solve problem . You have to put datasrc in table tag as shown in example and change your xml
Hi

Why not you do this:

 <NewsItem>
<Date taborder="1">Date</Date>
<Title taborder="2">Title</Title>
<Link taborder="3">Link</Link>
<Body taborder="4">test</Body>
</NewsItem>
<NewsItem>
    .
    .
    .
    .
    .


and put datafld like this : <span dataFld="Date">

Hope this helps ! :-)


By Nab
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses
Course of the Month17 days, 4 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question