<pre name="code" class="html"><?xml version="1.0"?>
<story>
<storyinfo>
<author>John Fleck</author>
<datewritten>June 2, 2002</datewritten>
<keyword>example </keyword>
<keyword1>example 1</keyword1>
<keyword2>example 2</keyword2>
<keyword3>example 3</keyword3>
<keyword4>example 4</keyword4>
<keyword5>example 5</keyword5>
<keyword6>example 6</keyword6>
</storyinfo>
<keyword7>example 7</keyword7>
<keyword8>example 8</keyword8>
<keyword9>example 9</keyword9>
<keyword10>example 10</keyword10>
<body>
<headline>This is the headline</headline>
<para>This is the body text.</para>
</body>
</story>
要解析以上XML文件,利用LIBXML库,源代码如下

本文档展示了如何使用LIBXML库来遍历并读取XML文件中的所有属性和内容,包括作者、写作日期、关键词和文章正文。
最低0.47元/天 解锁文章
853

被折叠的 条评论
为什么被折叠?



