可以使用QDomDocument来读取该节点:
QDomDocument doc;
doc.setContent("<1.连接方式选择telnet Destination=\"1;1;0.181421;1.00012;0;0.100962;0;1;1;0\" Open=\"false\"/>");
QDomNode node = doc.firstChild(); // 获取根节点
QString tagName = node.nodeName(); // 获取标签名
QDomNamedNodeMap attributes = node.attributes(); // 获取节点属性列表
if (tagName == "1.连接方式选择telnet") {
QString destination = attributes.namedItem("Destination").nodeValue(); // 获取Destination属性值
QString open = attributes.namedItem("Open").nodeValue(); // 获取Open属性值
}
其中,namedItem()
方法可以根据属性名获取指定的属性节点,并通过nodeValue()
方法获取属性值。