0
HTML 파일을 구문 분석하기 위해 htmlcleaner를 사용합니다. 다음은 html 파일의 예입니다.html 파일에서 링크 가져 오기
.......<div class="name"><a href="http://example.com">Name</a></div>;......
나는
HtmlCleaner cleaner = new HtmlCleaner();
CleanerProperties props = cleaner.getProperties();
props.setAllowHtmlInsideAttributes(true);
props.setAllowMultiWordAttributes(true);
props.setRecognizeUnicodeChars(true);
props.setOmitComments(true);
rootNode = cleaner.clean(htmlPage);
TagNode linkElements[] = rootNode.getElementsByName("div",true);
for (int i = 0; linkElements != null && i < linkElements.length; i++)
{
String classType = linkElements.getAttributeByName("name");
if (classType != null)
{
if(classType.equals(class)&& classType.equals(CSSClassname)) { linkList.add(linkElements); }
}
System.out.println("TagNode" + linkElements.getText());
linkList.add(linkElements);
}
and then add all of this name's to listview using
TagNode=linkelements.getText().toString()
내 코드에서이 구조를 사용하여 단어 Name
를 얻을;
하지만 내 사례에서 어떻게 링크를 얻을 수 있는지 이해할 수 없습니다. 나는 http://exxample.com 링크를 얻고 싶지만 무엇을 해야할지 모르겠다.
도와주세요. 나는 튜토리얼을 읽고 함수를 사용했으나 할 수 없었다.
P. 내 나쁜 영어 죄송합니다
네 대답은 ... 네 .... 나는 내가 사용하는 모든 코드를 복사하지 않는다는 것을 알지만 ... 응용 프로그램은 작동합니다 .... 내 문제는 웹 사이트에서 링크를 얻습니다. .HTMLcleaner는 안드로이드에서 html을 파싱 할 때 사용하기에 더 쉽습니다. & htmlcleaner를 사용하여 일반 DOM 트리를 만들 수 있습니다 ...) 시도해보십시오.) –