代码之家  ›  专栏  ›  技术社区  ›  Rahul Vyas

在iphonesdk中解析xhtml?

  •  0
  • Rahul Vyas  · 技术社区  · 16 年前

    我想解析一个xhtml文件并在UITableView中显示。解析xhtml文件的最佳方式是什么,这样我就可以在浏览器中显示它。下面是一个示例xhtml源代码

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Wheel</title>
    <link rel="stylesheet" type="text/css" href="../styles/stylesheet.css"/>
    <link rel="stylesheet" type="application/vnd.adobe-page-template+xml" href="../page-template.xpgt"/>
    </head>
    <body>
    <h2 class="h2"><a id="page_x"></a><a id="page_xi"></a><a id="page_xii"></a><a id="table"></a>TABLE OF CONTENTS</h2>
    <p class="content2"><strong><a href="Big Idea.html">WHAT&#8217;S THE BIG IDEA?</a></strong></p>
    <p class="content2"><strong><a href="Choosing.html">CHOOSING</a></strong></p>
    <p class="content2"><strong><a href="author note.html">AUTHOR&#8217;S NOTE</a></strong></p>
    <p class="content2"><strong><a href="part1.html">THE STORY OF OG</a></strong></p>
    <p class="content"><a href="chapter01.html">Chapter &#35;&#160; 1:&#160;&#160;Og Gets an Idea</a></p>
    <p class="content"><a href="chapter02.html">Chapter &#35;&#160; 2:&#160;&#160;Dazed By the Possibilities</a></p>
    <p class="content"><a href="chapter03.html">Chapter &#35;&#160; 3:&#160;&#160;Aargh!</a></p>
    <p class="content"><a href="chapter04.html">Chapter &#35;&#160; 4:&#160;&#160;The Grunt of the Town</a></p>
    <p class="content"><a href="chapter05.html">Chapter &#35;&#160; 5:&#160;&#160;Getting Around To It</a></p>
    <p class="content"><a href="chapter05.html">Chapter &#35;&#160; 6:&#160;&#160;Og&#8217;s Head Is Full, But the Cupboard Is Empty</a></p>
    <p class="content"><a href="chapter07.html">Chapter &#35;&#160; 7:&#160;&#160;The Big Meating</a></p>
    <p class="content"><a href="chapter08.html">Chapter &#35;&#160; 8:&#160;&#160;The Path Is Made By Walking On It</a></p>
    <p class="content"><a href="chapter09.html">Chapter &#35;&#160; 9:&#160;&#160;Crouch</a></p>
    <p class="content"><a href="chapter10.html">Chapter &#35;10:&#160;&#160;An Arrow to the Heart of the Matter</a></p>
    <p class="content"><a href="chapter11.html">Chapter &#35;11:&#160;&#160;Nothing to Get</a></p>
    <p class="content"><a href="chapter12.html">Chapter &#35;12:&#160;&#160;Smoke From a Fire, Flakes From a Stone</a></p>
    <p class="content"><a href="chapter13.html">Chapter &#35;13:&#160;&#160;The Happy Accident</a></p>
    <p class="content"><a href="chapter14.html">Chapter &#35;14:&#160;&#160;The Center Is Everything</a></p>
    <p class="content"><a href="chapter15.html">Chapter &#35;15:&#160;&#160;Sleeping Like a Rock</a></p>
    <p class="content"><a href="chapter16.html">Chapter &#35;16:&#160;&#160;Follow Your Feet</a></p>
    <p class="content"><a href="chapter17.html">Chapter &#35;17:&#160;&#160;Everyone&#8217;s Turn</a></p>
    <p class="content2"><a href="Best Practices.html"><strong>WHAT OG LEARNED:</strong> 12 Wheely Good Best Practices</a></p>
    <p class="content2"><a href="Tooling.html"><strong>TOOLING UP:</strong> 35 Ways to Get the Wheels Turning</a></p>
    <p class="content2"><a href="stone.html"><strong> IN STONE:</strong> The Tools and Techniques Contest</a></p>
    <p class="content2"><a href="Nexting.html"><strong>NEXTING:</strong> the Future</a></p>
    <p class="content2"><a href="Staying.html"><strong> ROLL:</strong> Resources for Thinking Outside the Cave</a></p>
    <p class="content2"><a href="ogcasting.html"><strong>O<span class="smallcaps2">G</span>CASTING:</strong> Your Free Audio Bonus</a></p>
    <p class="content2"><a href="about_author.html"><strong>ABOUT THE AUTHOR</strong></a></p>
    </body>
    </html>
    
    2 回复  |  直到 16 年前
        1
  •  1
  •   xoail    15 年前

    我强烈建议使用libxml2解析html或xhtml。我遵循了这个教程 http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html 但是需要几次迭代才能使循环正常运行。

        2
  •  0
  •   Amitg2k12    14 年前

    另一种方法是使用UIWebView,让它只用于加载文档并使用DOM类访问数据