[解決済み] この記号を検出する方法。Androidで'¦' (破線枠のOBJ) [重複] を検出する方法
2022-03-12 13:03:08
質問
WordpressサイトのXMLをパースするアプリを作っています。Wordpress上で動作するため、使用されている多くのHTMLが実際にはテキストの一部としてデータベースに保存されており、HTMLを削除しようとするとこの記号が表示されます。

ここで正しく表示されるかどうかわかりませんが、これは破線のボックス内にある小さなOBJシンボルで、HTMLパーサーが画像を解析しようとするときはいつもテキストに表示されます。基本的に、私はこれが発生したときに検出し、それを削除したいのですが、私は私のコードでそれを検出することができないので困っています。
まず最初に書くHTMLコードは以下の通りです。
05-21 11:26:05.402: I/System.out(6546):
<a id="dd_start"></a><p><strong><a href="http://movieboozer.com/wp-content/uploads/2012/05/the-avengers-poster.jpg" onclick="return TrackClick('http%3A%2F%2Fmovieboozer.com%2Fwp-content%2Fuploads%2F2012%2F05%2Fthe-avengers-poster.jpg','the-avengers-poster')"><img class="alignleft wp-image-22470" style="margin-left: 10px; margin-right: 10px;" title="the-avengers-poster" src="http://movieboozer.com/wp-content/uploads/2012/05/the-avengers-poster.jpg" onclick="return TrackClick('http%3A%2F%2Fmovieboozer.com%2Fwp-content%2Fuploads%2F2012%2F05%2Fthe-avengers-poster.jpg','the-avengers-poster')" alt="" width="208" height="308" /></a>By: <a href="http://neauxreelidea.blogspot.com/" onclick="return TrackClick('http%3A%2F%2Fneauxreelidea.blogspot.com%2F','Bill+Arceneaux')">Bill Arceneaux</a> </strong><strong></strong><strong>(<a href="#verdict">A Toast</a>)<br /></strong><strong>Note: There is a rating embedded within this post, please visit this post to rate it. </strong></p><p>I used to collect comic books. Yes, I admit it. I got swept up in the fantasy of characters with unique abilities beyond those of normal people, fighting over exaggerated villains in an effort to save their hometown, and in some cases, the world. I mostly focused on the Superman comics – during the period of time when he became pure energy (I was probably one of the few that liked that story arc) – but I certainly hadn’t chosen a side in the DC vs. Marvel fight. Why pigeonhole yourself to just one brand?<span id="more-22462"></span></p><p><a href="http://movieboozer.com/wp-content/uploads/2012/05/200px-Action_Comics_1.jpg" onclick="return TrackClick('http%3A%2F%2Fmovieboozer.com%2Fwp-content%2Fuploads%2F2012%2F05%2F200px-Action_Comics_1.jpg','200px-Action_Comics_1')"><img class="aligncenter size-full wp-image-22467" title="200px-Action_Comics_1" src="http://movieboozer.com/wp-content/uploads/2012/05/200px-Action_Comics_1.jpg" onclick="return TrackClick('http%3A%2F%2Fmovieboozer.com%2Fwp-content%2Fuploads%2F2012%2F05%2F200px-Action_Comics_1.jpg','200px-Action_Comics_1')" alt="" width="200" height="277" /></a></p><p style="text-align: center;">Never got my hands on that issue.</p><p>My collection eventually stopped – only a little more than a handful of issues remain. Was this just a passing fancy? I think, personally, I just yearned for something more; something to give the pages a new life in my eyes, without insulting my devotion to the mythology. In the last decade, we’ve seen movies that range from bastardized toy commercials to unique creative interpretations. But, have we seen the best that comic book movies can be?</p><p>If we haven’t yet, <em>The Avengers</em> might just be it. The culmination of millions of dollars in production budgets and years of origin stories, this story has HIGH expectations:</p><p>After finding his way out of a cosmic abyss (as seen in <em>Thor</em>), Loki (Tom Hiddleston) makes a play and captures the Tesseract (as seen in <em>Captain America: The First Avenger</em>) – a cube of energy that could prove dangerous if in the wrong hands – from S.H.I.E.L.D. (as seen in all previous Marvel Cinematic Universe films). Nick Fury (Samuel L. Jackson) is forced to restart the Avengers Initiative – a program to bring together Earth’s mightiest heroes – in a last ditch effort to get the cube back and stop Loki from leading an alien army.</p><p>Of course, this means that Fury must bring together a group of people who probably shouldn’t be in the same room together; Iron Man (Robert Downey Jr.), CaptainAmerica(Chris Evans), Dr. Bruce Banner AKA The Hulk (Mark Ruffalo), Thor (Chris Hemsworth), Black Widow (Scarlett Johansson) and Hawkeye (Jeremy Renner). Can these heroes put their difference aside and conquer their own inner problems in time to save the world?</p><p><strong>A Toast</strong></p><p>Have you ever had an awesome-gasm? … Did I just invent a new word to describe a movie?</p><p><a href="http://movieboozer.com/wp-content/uploads/2012/05/hulk.jpg" onclick="r.......
そして、その後がこんな感じです。
05-21 11:26:05.585: I/System.out(6546): : Bill Arceneaux (A Toast)
05-21 11:26:05.585: I/System.out(6546): Note: There is a rating embedded within this post, please visit this post to rate it.
05-21 11:26:05.585: I/System.out(6546): I used to collect comic books. Yes, I admit it. I got swept up in the fantasy of characters with unique abilities beyond those of normal people, fighting over exaggerated villains in an effort to save their hometown, and in some cases, the world. I mostly focused on the Superman comics – during the period of time when he became pure energy (I was probably one of the few that liked that story arc) – but I certainly hadn’t chosen a side in the DC vs. Marvel fight. Why pigeonhole yourself to just one brand?
05-21 11:26:05.585: I/System.out(6546): 
05-21 11:26:05.585: I/System.out(6546): Never got my hands on that issue.
05-21 11:26:05.585: I/System.out(6546): My collection eventually stopped – only a little more than a handful of issues remain. Was this just a passing fancy? I think, personally, I just yearned for something more; something to give the pages a new life in my eyes, without insulting my devotion to the mythology. In the last decade, we’ve seen movies that range from bastardized toy commercials to unique creative interpretations. But, have we seen the best that comic book movies can be?
05-21 11:26:05.585: I/System.out(6546): If we haven’t yet, The Avengers might just be it. The culmination of millions of dollars in production budgets and years of origin stories, this story has HIGH expectations:
05-21 11:26:05.589: I/System.out(6546): After finding his way out of a cosmic abyss (as seen in Thor), Loki (Tom Hiddleston) makes a play and captures the Tesseract (as seen in Captain America: The First Avenger) – a cube of energy that could prove dangerous if in the wrong hands – from S.H.I.E.L.D. (as seen in all previous Marvel Cinematic Universe films). Nick Fury (Samuel L. Jackson) is forced to restart the Avengers Initiative – a program to bring together Earth’s mightiest heroes – in a last ditch effort to get the cube back and stop Loki from leading an alien army.
05-21 11:26:05.589: I/System.out(6546): Of course, this means that Fury must bring together a group of people who probably shouldn’t be in the same room together; Iron Man (Robert Downey Jr.), CaptainAmerica(Chris Evans), Dr. Bruce Banner AKA The Hulk (Mark Ruffalo), Thor (Chris Hemsworth), Black Widow (Scarlett Johansson) and Hawkeye (Jeremy Renner). Can these heroes put their difference aside and conquer their own inner problems in time to save the world?
05-21 11:26:05.589: I/System.out(6546): A Toast
05-21 11:26:05.589: I/System.out(6546): Have you ever had an awesome-gasm? … Did I just invent a new word to describe a movie?
05-21 11:26:05.589: I/System.out(6546): 
05-21 11:26:05.589: I/System.out(6546): HULK SMASH EXPECTATIONS!
05-21 11:26:05.589: I/System.out(6546): With a cast of characters and actors this big, you would think things might get a bit muddled. But, with lots of clever photography, editing and dialogue, everything works out. Each hero – even Hawkeye and Black Widow – gets time to shine. And I don’t just mean moments where they look pretty and badass; each hero has personality and conflict. We actually get a little bit of depth here! It could have easily been a dumb action film, but instead chose to be a really good comic book.
05-21 11:26:05.589: I/System.out(6546): Marvel could’ve easily picked a team of hack writers and a yes man director to helm this project, expecting to make their money back on brand recognition alone. Instead, they picked a fan friendly writer/director who understands how the audience feels about these characters, and really delivered something special. Sure, the depth I described doesn’t go into superhero psychology levels, but it’s exactly where we need it to be. This really is just about perfect.
05-21 11:26:05.589: I/System.out(6546): Create a Drink
05-21 11:26:05.589: I/System.out(6546): At one point in the film, Loki is offered a drink. He turns it down, but that doesn’t mean you shouldn’t. Just for fun, come up with your own Loki inspired beverage (but be safe about it). Some people at the midnight screening I attended were dressed as their favorite characters; why not pay homage to them in liquid courage form?
05-21 11:26:05.589: I/System.out(6546): Verdict
05-21 11:26:05.589: I/System.out(6546): 
05-21 11:26:05.589: I/System.out(6546): Comic book movies rarely get any better than this. This isn’t to knock the other superhero flicks coming out this year (they’ll probably be great for different reasons), but the bar has been reset. Maybe the genre should be split into comic book, graphic novel and one off categories, in an effort to better tell the good from the bad? All I know for sure is, I feel like dusting off my old Action Comics issues.
この問題は、アンドロイドのシステムだけでなく、Javaにも原因があるような気がしています。
ご協力ありがとうございました。
編集する この記号は、HTMLの中で最初に出現する場所です。
<span id="more-22462"></span></p><p><a href="http://movieboozer.com/wp-content/uploads/2012/05/200px-Action_Comics_1.jpg" onclick="return TrackClick('http%3A%2F%2Fmovieboozer.com%2Fwp-content%2Fuploads%2F2012%2F05%2F200px-Action_Comics_1.jpg','200px-Action_Comics_1')"><img class="aligncenter size-full wp-image-22467" title="200px-Action_Comics_1" src="http://movieboozer.com/wp-content/uploads/2012/05/200px-Action_Comics_1.jpg" onclick="return TrackClick('http%3A%2F%2Fmovieboozer.com%2Fwp-content%2Fuploads%2F2012%2F05%2F200px-Action_Comics_1.jpg','200px-Action_Comics_1')" alt="" width="200" height="277" />
解決方法は?
を使用することができます。
Html.fromHtml
を利用して、HTMLコンテンツから表示可能なスタイル付きテキストを取得します。スタイル付きテキストから画像情報を削除するには、以下のコードを使用します。
public static Spanned removeImageSpanObjects(String inStr) {
SpannableStringBuilder spannedStr = (SpannableStringBuilder) Html
.fromHtml(inStr.trim());
Object[] spannedObjects = spannedStr.getSpans(0, spannedStr.length(),
Object.class);
for (int i = 0; i < spannedObjects.length; i++) {
if (spannedObjects[i] instanceof ImageSpan) {
ImageSpan imageSpan = (ImageSpan) spannedObjects[i];
spannedStr.replace(spannedStr.getSpanStart(imageSpan),
spannedStr.getSpanEnd(imageSpan), "");
}
}
return spannedStr;
}
関連
-
[解決済み] Javaでのスキャナが動作しない
-
[解決済み] Javaにおけるシンボリック参照
-
[解決済み] Java の文字列インデックスが範囲外です。0 [閉店]
-
[解決済み] Java- <T extends Comparable<T>>の意味?
-
[解決済み] Androidのソフトキーボードをプログラムで閉じる/隠すにはどうすればよいですか?
-
[解決済み] Androidでアクティビティ起動時にEditTextにフォーカスが当たらないようにする方法
-
[解決済み] AndroidのListViewで画像を遅延ロードする方法
-
[解決済み] Androidで画面の大きさをピクセル単位で取得する方法
-
[解決済み] Androidアプリケーションのアクティビティ間でデータを受け渡すにはどうすればよいですか?
-
[解決済み] Androidで現在の時刻と日付を取得する方法
最新
-
nginxです。[emerg] 0.0.0.0:80 への bind() に失敗しました (98: アドレスは既に使用中です)
-
htmlページでギリシャ文字を使うには
-
ピュアhtml+cssでの要素読み込み効果
-
純粋なhtml + cssで五輪を実現するサンプルコード
-
ナビゲーションバー・ドロップダウンメニューのHTML+CSSサンプルコード
-
タイピング効果を実現するピュアhtml+css
-
htmlの選択ボックスのプレースホルダー作成に関する質問
-
html css3 伸縮しない 画像表示効果
-
トップナビゲーションバーメニュー作成用HTML+CSS
-
html+css 実装 サイバーパンク風ボタン
おすすめ
-
[解決済み] トークンのシンタックスエラー、これらのトークンを削除してください [closed].
-
[解決済み] 環境変数JAVA_OPTSの使い方を教えてください。
-
[解決済み] javac ソースファイルが見つかりません
-
[解決済み] Javaでのスキャナが動作しない
-
[解決済み] javaでAnnotation Inheritanceのようなものはあるのでしょうか?
-
[解決済み] どのように配列の10未満の値(x * 2)を倍増するコードを取得するには?(Java)
-
[解決済み] Java- <T extends Comparable<T>>の意味?
-
[解決済み] タイプの安全性。アンチェック・キャスト
-
[解決済み] Spring ApplicationContext - リソースリーク: 'context' が閉じられない
-
[解決済み] ヘッドリカーシオンとテールリカーシオンの違い [重複]について