포럼 회원으로 등록하신분만 다운로드가 가능합니다. 최대 업로드 가능한 용량은 20MB 입니다.

출처: http://kldp.org/node/64566
==============

limxml2 라이브러리를 이용해서 어트리뷰트 값을 가져오는 방법이 무엇인가요?

아래와 같은 xml 문서가 있습니다. 이 문서에서 node 의 type 인 1을 가져오고 싶습니다.

<message>
<node type="1">
 <to> home </to>
 <from> house </from>
</node>
</message>

위 문서를 아래 소스를 응용해서 어트리뷰터 값을 가져 올 수 있을까요?

static void
print_element_names(xmlNode * a_node)
{
    xmlNode *cur_node = NULL;

    for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
        if (cur_node->type == XML_ELEMENT_NODE) {
            printf("node type: Element, name: %sn", cur_node->name);
        }

        print_element_names(cur_node->children);
    }
}

int
main(int argc, char **argv)
{
    xmlDoc *doc = NULL;
    xmlNode *root_element = NULL;

    if (argc != 2)
        return(1);

    doc = xmlReadFile(argv[1], NULL, 0);

    if (doc == NULL) {
        printf("error: could not parse file %sn", argv[1]);
    }

    root_element = xmlDocGetRootElement(doc);

    print_element_names(root_element);

    xmlFreeDoc(doc);

    xmlCleanupParser();

    return 0;
}

답변 좀 꼭 부탁드립니다.

xmlGetProp()함수가 있었네요. 이거 사용하면 되네요 *^^*

List of Articles
번호 제목 글쓴이 날짜sort 조회 수
93 Yocto project 소개자료 [2] 고도리 2019-08-24 957
92 Yocto zynq howto - 예전자료 고도리 2019-08-24 285
91 apache-1.3.33 arm porting by tssuk [3] 고도리 2013-05-21 3340
90 i2c scan하는 코드입니다. 고도리 2012-07-27 5338
89 dropbear ssh daemon 포팅하기 [1] 고도리 2012-06-30 5850
88 ffmpeg을 이용한 camera 영상 저장 file [1] 고도리 2012-05-01 5894
87 Linux application에서의 clock과 system timer설정 고도리 2011-08-15 7384
86 ffmpeg x86 compile & cross compile howto file 고도리 2011-08-05 7833
85 oss를 이용한 read, write, read/write program file [2] 고도리 2011-01-25 10533
84 GIT 사용법 (ProGIT) - 2.6. 태그(TAGS) 붙이기 [2] JhoonKim 2010-02-09 15136
83 GIT 사용법 (ProGIT) - 2.5. 원격 저장소의 사용 방법 [2] JhoonKim 2010-02-04 16063
82 GIT 사용법 (ProGIT) - 2.4. 작업의 취소 [1] JhoonKim 2010-02-03 15113
81 GIT 사용법 (ProGIT) - 2.3. 위탁 이력의 열람 file [1] JhoonKim 2010-02-03 13308
80 GIT 사용법 (ProGIT) - 2.2. GIT 저장소(Repository)에 기록 file [2] JhoonKim 2010-01-21 16033
79 GIT 사용법 (ProGIT) - 2.1. GIT 저장소(Repository)의 취득 JhoonKim 2010-01-20 18462
78 GIT 사용법 (ProGIT) - 1.5. 최초 GIT의 환경 설정 [3] JhoonKim 2010-01-13 16605
77 GIT 사용법 (ProGIT) - 1.4. GIT 설치 JhoonKim 2010-01-11 21208
76 GIT 사용법 (ProGIT) - 1.2. GIT 개발 역사 / 1.3. GIT 기본 ... file [3] JhoonKim 2010-01-10 14797
75 GIT 사용법 (ProGIT) - 1.1. 버전 관리 시스템의 개념 file [6] JhoonKim 2010-01-07 19510
74 I.MX Multimedia and Applications Framework 기술자료 ... file [2] 장석원 2009-10-26 11060

사용자 로그인