이 페이지에서

QDomAttr Class

QDomAttr 클래스는 QDomElement 의 하나의 속성을 나타냅니다. 더 보기...

헤더: #include <QDomAttr>
CMake: find_package(Qt6 REQUIRED COMPONENTS Xml)
target_link_libraries(mytarget PRIVATE Qt6::Xml)
qmake: QT += xml
상속: QDomNode

참고: 이 클래스의 모든 함수는 재진입 가능합니다.

공개 함수

QDomAttr()
QDomAttr(const QDomAttr &attr)
QString name() const
QDomNode::NodeType nodeType() const
QDomElement ownerElement() const
void setValue(const QString &value)
bool specified() const
QString value() const
QDomAttr &operator=(const QDomAttr &other)

상세 설명

예를 들어, 다음 XML은 자식 요소는 없지만 두 개의 속성을 가진 요소를 생성합니다.

<link href="http://qt-project.org" color="red" />

다음과 같은 코드를 사용하여 요소의 속성에 접근할 수 있습니다.

QDomElement e;
//...
QDomAttr a = e.attributeNode("href");
cout << qPrintable(a.value()) << '\n';   // prints "http://qt-project.org"
a.setValue("http://qt-project.org/doc"); // change the node's attribute
QDomAttr a2 = e.attributeNode("href");
cout << qPrintable(a2.value()) << '\n';  // prints "http://qt-project.org/doc"

이 예제는 또한 요소에서 가져온 속성을 변경하면 해당 요소의 속성도 변경된다는 점을 보여줍니다. 요소 속성의 값을 변경하지 않으려면 cloneNode()를 사용하여 속성의 독립적인 복사본을 가져와야 합니다.

QDomAttr는 속성의 name() 및 value()를 반환할 수 있습니다. 속성의 값은 setValue()를 사용하여 설정됩니다. specified()가 true를 반환하면 해당 값은 setValue()를 통해 설정된 것입니다. 이 속성이 연결된 노드(있는 경우)는 ownerElement()에 의해 반환됩니다.

문서 객체 모델(Document Object Model)에 대한 자세한 내용은 http://www.w3.org/TR/REC-DOM-Level-1/ 및 http://www.w3.org/TR/DOM-Level-2-Core/을 참조하십시오. DOM 구현에 대한 보다 일반적인 소개는 QDomDocument 문서를 참조하십시오.

멤버 함수 문서

QDomAttr::QDomAttr()

빈 속성을 생성합니다.

QDomAttr::QDomAttr(const QDomAttr &attr)

attr 의 복사본을 생성합니다.

복사본의 데이터는 공유됩니다(얕은 복사): 한 노드를 수정하면 다른 노드도 함께 변경됩니다. 깊은 복사를 하려면 cloneNode()를 사용하십시오.

QString QDomAttr::name() const

속성의 이름을 반환합니다.

QDomNode::NodeType QDomAttr::nodeType() const

AttributeNode 를 반환합니다.

QDomElement QDomAttr::ownerElement() const

이 속성이 연결된 요소 노드를 반환하거나, 이 속성이 어떤 요소에도 연결되어 있지 않은 경우 ` null node `를 반환합니다.

void QDomAttr::setValue(const QString &value)

속성의 값을 value 로 설정합니다.

value()도 참조하십시오 .

bool QDomAttr::specified() const

사용자가 setValue()을 통해 속성을 설정한 경우 true 를 반환합니다. 값이 지정되거나 설정되지 않은 경우 false 를 반환합니다.

setValue()도 참조하십시오 .

QString QDomAttr::value() const

속성의 값을 반환하며, 속성이 지정되지 않은 경우에는 빈 문자열을 반환합니다.

specified() 및 setValue()도 참조하십시오 .

QDomAttr &QDomAttr::operator=(const QDomAttr &other)

이 DOM 속성에 ` other `를 할당합니다.

복사된 데이터는 공유됩니다(표면 복사): 한 노드를 수정하면 다른 노드도 함께 변경됩니다. 심층 복사를 하려면 cloneNode()를 사용하십시오.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.