0
我需要编译一个模式,以获得跨度的名称,但徒劳无功我不能拥有我想要的可能是这种模式写入的方式我知道我做了一些不完全正确的事情..这是我的html代码:我如何提取使用java的跨度名称?
<span class="libelleAttributPageParametrage">
"Libellé de facturation"
<font color="#C60307">*</font>
</span>
,这是我的Java代码:
public List<String> getAllSpan()
{
String HTMLSource = priceSelenium.getHtmlSource();
priceSelenium.getBodyText();
List<String> ListOfSpan = new ArrayList<String>();
Pattern p = Pattern.compile("<SPAN[^>]*>([\\w\\d\\s\\n\\r()/°@\\.\\-àáâãäåçèéêëìíîïðòóôõöùúûüýÿ]*)</SPAN>");
Matcher m = p.matcher(HTMLSource);
while (m.find())
{
if (!m.group(1).isEmpty())
{
ListOfSpan.add(m.group(1));
}
}
return ListOfSpan;
}
,什么我需要在我的ListOfSpan是: “Libellé德facturation” 提前
感谢
请不要使用RegEx解析HTML,因为它会[驱动你į̷̷͚̤̤̖̦͍͗̒̈̅̄n̨͖͓̹͍͎͔͈̝͐ͪ͛̄͛ṣ̷̵̞̦ͤ̅̉̋ͪ͑͛ͥ͜a̷̘͖̮͔͎͛̇̏̒͆̆͘n͇͔̤̼͙̩͖̭ͤ͋̉͌͟eͥ͒ͥ͒](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454)。改为使用HTML解析器 – HashimR 2012-08-02 08:31:44