[はてなブログ]SyntaxhHighlighterを使ってXmlを記載する方法
SyntaxhHighlighterを使ってみてjavaでは問題にならなかったが、Xmlのコードを記載するときに問題が起きた。何故か文字が消えてしまう。
対処方法
1.こちらのサイトで文字列に<pre class="brush: xml;" ></pre>の中に記載したいコードを入力する。
2.変換結果にコード内の&、"、<、>を実体参照に変換したものが生成されるので、それを<pre class="brush: xml;" ></pre>の中に記載することでSyntaxhHighlighterが正常に動作する。
実際に変換したものがこちら
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/txtView" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout>