操作我有一個html文件,例如:jsoup:文本
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
我已經用Java編寫的方法,這些文字符號從拉丁文到西里爾文轉換,是這樣的:
public static char changeLetterLatCyr(char charSent) {
char l_A = 'A',
l_a = 'a',
l_B = 'B',
l_b = 'b',
r_A = 'А',
r_a = 'а',
r_B = 'Б',
r_b = 'б',
result = ' ';
if (charSent == l_A) {
result = r_A;
} else if (charSent == l_a) {
result = r_a;
} else if (charSent == l_B) {
result = r_B;
} else if (charSent == l_b) {
result = r_b;
} else {
result = charSent;
}
return result;
}
如何在保存所有標籤結構的文檔中的所有文本上實現我的功能?該函數將每個字符更改爲特定。
我需要這樣的結果:
<!DOCTYPE html>
<html>
<body>
<h1>some manipulation on text</h1>
<p>some manipulation on text</p>
</body>
</html>
你可以添加自己的功能? –
public static char changeLetterLatCyr(char charSent){ char l_A ='A', l_a ='a', l_C ='C', l_c ='c'; if(charSent == 1_A){ result = r_A; else if(charSent == 1_a){ result = r_a; result = r_b; else if(charSent == 1_C){ result = r_C; else if(charSent == 1_c){ result = r_c; 返回結果; } 它將拉丁符號轉換爲西里爾文。 – Seomat
更新您的問題,添加此代碼。 –