我的来源是:查找元素
<content>
<caption>text 1</caption>
<element1>Notepad is a basic text-editing program and it's most commonly used to view or edit text files. A text <bold>file</bold> is a <a>file</a> type typically identified by the .txt file name extension.</element1>
<section1>
<element2>Notepad is a basic text-editing program and it's most commonly used to view or edit text files. A text file is a file type typically identified by the .txt file name extension.</element2>
</section1>
</content>
我试图提取并为元素打造独一无二的ID(它可以是任何元素),其中有两个孩子(字符元素)和文本,还有只有文本的元素。 <bold>
和<a>
元素不应该分开。
<caption id="id1">Text 1</caption>
<element1 id="id2">Notepad is a basic text-editing program and it's most commonly used to view or edit text files. A text <bold>file</bold> is a <a>file</a> type typically identified by the .txt file name extension.</element1>
<element2 id="id3">Notepad....</element2>
任何想法,将不胜感激......
你的输出格式是和?你想跳过他们吗? –
是的我想只提取包含字符串/字符串+子元素(字符)元素的元素。只有子元素但没有PCDATA的元素不需要考虑。 – VSr
您的示例中的**标题**和** element2 **元素没有子元素,但仍具有id属性。这似乎与您说要从具有子项和文本的元素创建ID的位置相矛盾。它是否正确?谢谢! –