Source.HTMLDOM HTML 구문 분석
<!DOCTYPE html>
<html>
<body>
<h1 style="color:red">Hello World</h1>
<p id="demo" style="color:red">Click the button below to remove the style attribute from the header above.</p>
</body>
</html>
Parser.html는
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Parse</button>
<script>
function myFunction()
{
document.getElementsByTagName("H1")[0].removeAttribute("style");
document.getElementsByTagName("P")[0].removeAttribute("style");
};
</script>
</body>
</html>
지금 내가이었다에 대한 지침을 필요, 난 파서에서 구문 분석 단추를해야합니다. html로 source.html에 대한 함수를 적용하고 source.html의 같은 경로에 output.html로 저장하십시오.
친절하게 도와주세요 ...
당신은 파일 시스템에서 작동하는 서버 측 언어, PHP 같은 것을 사용해야 할 것입니다. 자바 스크립트 함수가 제대로 작동하지 않을 것이라고 생각합니다. FileSystem API가 제한적이라고 생각합니다. 당신은 PHP와 AJAX를보고 싶습니다. –
이것은 파싱에 관한 것이 아닙니다. 구문 분석은 브라우저가 DOM 트리를 구성하기 위해 수행하는 작업입니다. 따라서 DOM을 조작 할 때 문서가 이미 파싱되어 있어야합니다. –