douse8732 2012-12-12 07:03
浏览 20

如何获取存储在其他文件夹中的HTML文件中每个标记的所有元素标记和内容

Objective is to Get individual text segments from HTML file (not a single stream string of whole document.)

I want to scan html files for element tags and text content in between tag pair. I am thinking of doing it something like this :

//        var mytags = $('#trans_seg').find('*');
//        var total = mytags.length;
//    
//        for(i = 0; i <= total; i++){
//            console.log(mytags[i].textContent);
//        } 

Its done in console mode of firebug !

I applied this operation in existing HTML file, now how can i do it for other HTML files ?

i have tried somewhat like this:

$(document).ready(function(){
    data = '<?php echo mysql_real_escape_string(file_get_contents('test_html.html')); ?>';
    tags = data.find('*');
    alert($data.length);
});

But it is giving error "TypeError: data.find is not a function".

Do ask me question if it still not clear.

********** Edited *****************

i got this response when i alert data

<!--

To change this template, choose Tools | Templates

and open the template in the editor.

-->

<head>

    <title></title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>

<body>

    <div>TODO write content</div>

    <h1>My First Heading</h1>



    <p>My first paragraph.</p>

</body>

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 linux驱动,linux应用,多线程
    • ¥20 我要一个分身加定位两个功能的安卓app
    • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
    • ¥15 IAR程序莫名变量多重定义
    • ¥15 (标签-UDP|关键词-client)
    • ¥15 关于库卡officelite无法与虚拟机通讯的问题
    • ¥15 目标检测项目无法读取视频
    • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
    • ¥100 求采集电商背景音乐的方法
    • ¥15 数学建模竞赛求指导帮助