开发者

Show a little complex xml data in HTML by using <Input DATAFLD="..."></input>

Hi I'm trying to display xml data on a HTML page.

I don't have any problem with simple xml files like:

   <?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- Edited by XMLSpy® -->
    <note>
        <to>Tove<开发者_开发问答/to>
        <from>Jani</from>
        <heading>Reminder</heading>
        <body>Don't forget me this weekend!</body>
    </note>

Problem is more complex ones like:

<?xml version="1.0"?>
<!DOCTYPE addressbook SYSTEM "addressbook.dtd">
<addressbook>
    <contact>
        <name>Evren Ozturk</name>
        <address>Adress here!</address>
        <city>Varna</city>
        <zip>35500</zip>
        <phone>
            <mobile>0999999999</mobile>
            <landline>232-000-1234</landline>
            <fax>232-000-1234</fax>
        </phone>
        <email>blaa@live.com </email>
        <company>Asis Bg</company>
    </contact>
</addressbook>

In this example I can see these:name, address,city,zip,email,company. But I can't see values of mobile, landline and fax. Here are the codes I'm using to display data:

<HTML>
<HEAD>
<title>Evren Ozturk</TITLE>
</HEAD>
<BODY>
<XML id="addressbook" src="addressbook.xml"></XML>

    <!--XML DATA BOUND TABLE-->
    <table DATASRC="#addressbook" >
    <tr><thead bgcolor=tan>
          <th>name</th>
          <th>address</th>
          <th>city</th>
          <th>zip</th>
          <th>mobile</th>
          <th>landline</th>
          <th>fax</th>
          <th>email</th>
          <th>company</th></thead>
    </tr>
    <tr>
    <td><input DATAFLD="name"></input></td>
    <td><input DATAFLD="address"></input></td>
    <td><input DATAFLD="city"></input></td>
    <td><input DATAFLD="zip"></input></td>
    <td><input DATAFLD="mobile"></input></td>
    <td><input DATAFLD="landline"></input></td>
    <td><input DATAFLD="fax"></input></td>
    <td><input DATAFLD="email"></input></td>
    <td><input DATAFLD="company" ></input></td>
    </tr>
    </table>
    <hr color=SteelBlue width=500 height=5 align=left>


    </BODY>
    </HTML>

Here is an SS for result of these codes:

Cause of I'm new user I can't post picture 8D so I'm open for points 8P

I now there is no need to be mobile and ETC. inside the phone, but wherever I look: I just saw same tpye simple examples. I just want to do it this way 8) If you can help me it realy will be great. Thanks for giving your time.


A quick and dirty solution is to put your xml in an HTML <pre> tag. This renders any contained text "as is" preserving formatting, line breaks, spaces etc.


I found the solution:

<HTML>
<HEAD>
<title>Shenay Ozturk</TITLE>
</HEAD>
<BODY>
<XML id="addressbook" src="addressbook.xml"></XML>

<table cellpadding="0" cellspacing="0" DATASRC="#addressbook">
<tr>
    <td>
        <table >
        <tr><td>
            <thead bgcolor=#AAAAFF>
            <th width="50">name</th>
            <th width="50">address</th>
            <th width="50">city</th>
            <th width="50">zip</th>
            </thead>
        </td></tr>
        <tr>
        <td><input DATAFLD="name"></input></td>
        <td><input DATAFLD="address"></input></td>
        <td><input DATAFLD="city" ></input></td>
        <td><input DATAFLD="zip"></input></td>
        </tr>
        </table>
    </td>
    <td>
        <table DATASRC="#addressbook" DATAFLD="phone" >
        <tr><td>
            <thead bgcolor=#AAAAFF>
            <th width="50">mobile</th>
            <th width="50">landline</th>
            <th width="50">fax</th>
            </thead>
        </td></tr>
        <tr>
            <td><INPUT DATAFLD="mobile" ></INPUT></td>
            <td><input DATAFLD="landline" ></input></td>
            <td><input DATAFLD="fax" ></input></td>
        </tr>
        </table>
    </td>
    <td>
        <table >
        <tr><td>
            <thead bgcolor=#AAAAFF>
            <th width="50">email</th>
            <th width="50">company</th>
            </thead>
        </td></tr>
        <tr>
            <td><input DATAFLD="email"></input></td>
            <td><input DATAFLD="company" ></input></td>
        </tr>
        </table>
    </td>
</tr>
</table>
<hr color=SteelBlue width=500 height=5 align=left>
HTML close bla bla....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜