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 ()가 참을 반환하면 setValue()로 설정된 값입니다. 이 속성이 연결된 노드(있는 경우)는 ownerElement()로 반환됩니다.

문서 객체 모델에 대한 자세한 내용은 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()를 사용합니다.

© 2025 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.