English 中文(简体)
我怎么能够把XML添加到一个带有超文本链接的超文本网页上。
原标题:How can I add XML to an HTML page with a hyperlink

我要在我的超文本页上加上XML。 我愿把图西显示为1 h3,内容显示为1 p,而圆顶显示。

<>XML

<linkedin>
<discussion>
    <topic>This is the discussion name</topic>
    <content>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ligula mi, convallis eget iaculis id, euismod non arcu. Morbi porta.</content>
    <url>http://www.linkedin.com/groups/</url>
</discussion>

在这里,我想看一下产出的超文本:

<h3>This is the discussion name</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ligula mi, convallis eget iaculis id, euismod non arcu. Morbi porta.</p>
<a href="http://www.linkedin.com/groups/"></a>

Many Thanks, I hope this explanation of what I m stuck on makes sense.

最佳回答

www.un.org/Depts/DGACM/index_russian.htm 这就像它所看到的那样简单。 它没有处理儿童节点不在场的情况。

只是让你开始使用一个jax的要求。

<><><><>>><>>>>><>>>>>>

<!DOCTYPE>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type = "text/javascript" src = "script.js" defer = "defer"></script>
</head>
<body>

</body>
</html>

JS (script.js)

function getXML() {
    var xmlhttp,xmlDoc;
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET", "your-xml-file.xml", false);
    xmlhttp.send();
    xmlDoc = xmlhttp.responseXML;
    showDiscussions(xmlDoc);
}

function showDiscussions(xmlDoc) {
    var discHolder = document.createElement("DIV"),
        disc = xmlDoc.getElementsByTagName("discussion");
    for (var i = 0, j = disc.length; i < j; i++) {
        var topic = document.createElement("h3"),
            content = document.createElement("p"),
            url = document.createElement("a");

        topic.innerHTML = disc[i].getElementsByTagName("topic")[0].childNodes[0].nodeValue;
        discHolder.appendChild(topic);
        content.innerHTML = disc[i].getElementsByTagName("content")[0].childNodes[0].nodeValue;
        discHolder.appendChild(content);
        url.href = disc[i].getElementsByTagName("url")[0].childNodes[0].nodeValue;
        url.innerHTML = disc[i].getElementsByTagName("url")[0].childNodes[0].nodeValue;
        discHolder.appendChild(url);

    }

    document.body.appendChild(discHolder);
}

getXML();

我还建议使用jquery

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签