깃허브 블로그 sitemap.xml 에러 해결하기 (This page contains the following errors)

어느 순간부터 구글 Search Console에 Sitemaps 항목에서 다음과 같은 오류가 발생했다. 그래서 블로그url/sitemap.xml 로 확인해 보니깐

진짜 다음과 같은 오류가 발생하고 있었다.
다양한 이유가 있겠지만 일단 오류 내용이 xmlParseEntityRef: noname 이였다. 그리고 밑에 url들을 확인해 보니깐, 특정 게시물 부터 출력되기 시작했다.

다음과 같이 JPA Hint & Lock 이 게시물 밑으로 오류가 발생하고 있었다.
그래서 구글링을 해본 결과,
xml파일에 “&”이나 “<”, “>” 와 같이 특수 문자가 있으면 “xmlParseEntityRef: noname” 오류 발생합니다.
이런 내용을 찾을 수 있었다. 그래서 바로 제목을 & 에서 and 로 바꾸고 다시 올려보니깐

정상적으로 sitemap이 동작하는 걸 확인했다.
정 특수문자가 쓰고 싶으면
Solution 3 : Use CDATA sections (text inside a CDATA section will be ignored by the parser.) eg.
<![CDATA[ {XML DATA} ]]>
다음과 같이 cdata를 사용하라고 한다.
- Solution 1: Remove the ampersand.
- Solution 2: Encode the ampersand (that is replace the
&character with&). Remember to Decode when reading the XML text. - Solution 3: Use CDATA sections (text inside a CDATA section will be ignored by the parser.) eg. <![CDATA[some text & some more text]]>
참고
- https://stackoverflow.com/questions/7604436/xmlparseentityref-no-name-warnings-while-loading-xml-into-a-php-file
- https://www.happyjung.com/lecture/2550?sfl=mb_id%2C1&stx=happyjung&sst=wr_datetime&sod=desc&sop=and&page=27
댓글남기기