주요 콘텐츠

string

구문 분석된 HTML 트리를 string형으로 변환하기

    설명

    str = string(tree)htmlTree 객체 tree를 string형으로 변환합니다.

    string 함수를 사용하여 htmlTree 객체의 기본 HTML 코드를 검사할 수 있습니다. htmlTree 객체의 요소를 탐색하려면 findElement 함수를 사용합니다.

    예제

    예제

    모두 축소

    webread 함수를 사용하여 URL https://www.mathworks.com/help/textanalytics에서 HTML 코드를 읽어옵니다.

    url = "https://www.mathworks.com/help/textanalytics";
    code = webread(url);

    htmlTree 함수를 사용하여 HTML 코드를 구문 분석합니다.

    tree = htmlTree(code);

    findElement 함수를 사용하여 HTML 트리에서 단락을 모두 찾습니다. 단락은 요소 이름이 "P"인 노드입니다.

    subtrees = findElement(tree,"P");

    string 함수를 사용하여 하위 트리를 string형으로 변환합니다.

    str = string(subtrees)
    str = 18×1 string array
        "<P class="h1">↵  <A xmlns="http://www.w3.org/1999/xhtml" href="../index.html">Help Center</A>↵</P>"
        "<P>Text Analytics Toolbox™ provides algorithms and visualizations for preprocessing, analyzing, and modeling text data. Models created with the toolbox can be used in applications such as sentiment analysis, predictive maintenance, and topic modeling.</P>"
        "<P>Text Analytics Toolbox includes tools for processing raw text from sources such as equipment logs, news feeds, surveys, operator reports, and social media. You can extract text from popular file formats, preprocess raw text, extract individual words, convert text into numerical representations, and build statistical models.</P>"
        "<P>Using machine learning techniques such as LSA, LDA, and word embeddings, you can find clusters and create features from high-dimensional text datasets. Features created with Text Analytics Toolbox can be combined with features from other data sources to build machine learning models that take advantage of textual, numeric, and other types of data.</P>"
        "<P class="category_desc">Learn the basics of Text Analytics Toolbox</P>"
        "<P class="category_desc">Import text data into MATLAB<SUP>®</SUP> and preprocess it for analysis</P>"
        "<P class="category_desc">Develop predictive models using topic models and word embeddings</P>"
        "<P class="category_desc">Visualize text data and models using word clouds and text scatter plots</P>"
        "<P class="category_desc">Information on language support in Text Analytics Toolbox</P>"
        "<P>You clicked a link that corresponds to this MATLAB command:</P>"
    
    

    입력 인수

    모두 축소

    HTML 트리로, htmlTree 배열로 지정됩니다.

    출력 인수

    모두 축소

    string형으로, tree와 동일한 크기의 string형 배열로 반환됩니다.

    버전 내역

    R2018b에 개발됨

    모두 확장