lib

KoXml Namespace Reference

Functions

KOFFICECORE_EXPORT KoXmlElement namedItemNS (const KoXmlNode &node, const char *nsURI, const char *localName)
KOFFICECORE_EXPORT void load (KoXmlNode &node, int depth=1)
KOFFICECORE_EXPORT void unload (KoXmlNode &node)

Detailed Description

This namespace contains a few convenience functions to simplify code using TQDom (when loading OASIS documents, in particular).

To find the child element with a given name, use KoXml::namedItemNS.

To find all child elements with a given name, use TQDomElement e; forEachElement( e, parent ) { if ( e.localName() == "..." && e.namespaceURI() == KoXmlNS::... ) { ... } } Note that this means you don't ever need to use TQDomNode nor toElement anymore! Also note that localName is the part without the prefix, this is the whole point of namespace-aware methods.

To find the attribute with a given name, use TQDomElement::attributeNS.

Do not use getElementsByTagNameNS, it's recursive (which is never needed in KOffice). Do not use tagName() or nodeName() or prefix(), since the prefix isn't fixed.

Author
David Faure faure.nosp@m.@kde.nosp@m..org

Function Documentation

◆ load()

void KoXml::load ( KoXmlNode & node,
int depth = 1 )

Explicitly load child nodes of specified node, up to given depth.

This function has no effect if TQDom is used.

Definition at line 1548 of file KoXmlReader.cpp.

◆ namedItemNS()

KoXmlElement KoXml::namedItemNS ( const KoXmlNode & node,
const char * nsURI,
const char * localName )

A namespace-aware version of TQDomNode::namedItem(), which also takes care of casting to a TQDomElement.

Use this when a domelement is known to have only one child element with a given tagname.

Note: do NOT use getElementsByTagNameNS, it's recursive!

Definition at line 1531 of file KoXmlReader.cpp.

◆ unload()

void KoXml::unload ( KoXmlNode & node)

Unload child nodes of specified node.

This function has no effect if TQDom is used.

Definition at line 1560 of file KoXmlReader.cpp.