54 return element->tagName;
61 int rc = IXML_SUCCESS;
63 if (!element || !tagName) {
67 if (element->tagName) {
68 free(element->tagName);
70 element->tagName = strdup(tagName);
71 if (!element->tagName) {
72 rc = IXML_INSUFFICIENT_MEMORY;
82 if (!element || !name) {
86 attrNode = element->n.firstAttr;
88 if (attrNode->nodeName && strcmp(attrNode->nodeName, name) == 0) {
89 return attrNode->nodeValue;
91 attrNode = attrNode->nextSibling;
100 int errCode = IXML_SUCCESS;
102 if (!element || !name || !value) {
103 errCode = IXML_INVALID_PARAMETER;
107 errCode = IXML_INVALID_CHARACTER_ERR;
111 attrNode = element->n.firstAttr;
113 if (attrNode->nodeName && strcmp(attrNode->nodeName, name) == 0) {
117 attrNode = attrNode->nextSibling;
124 (
IXML_Document*)element->n.ownerDocument, name, &newAttrNode);
125 if (errCode != IXML_SUCCESS) {
129 attrNode->nodeValue = strdup(value);
130 if (!attrNode->nodeValue) {
132 errCode = IXML_INSUFFICIENT_MEMORY;
137 if (errCode != IXML_SUCCESS) {
142 if (attrNode->nodeValue) {
144 free(attrNode->nodeValue);
146 attrNode->nodeValue = strdup(value);
147 if (!attrNode->nodeValue) {
148 errCode = IXML_INSUFFICIENT_MEMORY;
159 if (!element || !name) {
160 return IXML_INVALID_PARAMETER;
163 attrNode = element->n.firstAttr;
165 if (attrNode->nodeName && strcmp(attrNode->nodeName, name) == 0) {
169 attrNode = attrNode->nextSibling;
174 if (attrNode->nodeValue) {
175 free(attrNode->nodeValue);
176 attrNode->nodeValue = NULL;
187 if (!element || !name) {
191 attrNode = element->n.firstAttr;
193 if (attrNode->nodeName && strcmp(attrNode->nodeName, name) == 0) {
197 attrNode = attrNode->nextSibling;
208 if (!element || !newAttr) {
209 return IXML_INVALID_PARAMETER;
211 if (newAttr->n.ownerDocument != element->n.ownerDocument) {
212 return IXML_WRONG_DOCUMENT_ERR;
214 if (newAttr->ownerElement) {
215 return IXML_INUSE_ATTRIBUTE_ERR;
218 newAttr->ownerElement = element;
220 attrNode = element->n.firstAttr;
222 if (attrNode->nodeName && node->nodeName &&
223 !strcmp(attrNode->nodeName, node->nodeName)) {
227 attrNode = attrNode->nextSibling;
231 IXML_Node* preSib = attrNode->prevSibling;
232 IXML_Node* nextSib = attrNode->nextSibling;
234 preSib->nextSibling = node;
237 nextSib->prevSibling = node;
239 if (element->n.firstAttr == attrNode) {
240 element->n.firstAttr = node;
249 if (element->n.firstAttr) {
250 IXML_Node* prevAttr = element->n.firstAttr;
251 IXML_Node* nextAttr = prevAttr->nextSibling;
254 nextAttr = prevAttr->nextSibling;
256 prevAttr->nextSibling = node;
257 node->prevSibling = prevAttr;
260 element->n.firstAttr = node;
261 node->prevSibling = NULL;
262 node->nextSibling = NULL;
286 if (!element || !oldAttr) {
290 attrNode = element->n.firstAttr;
299 attrNode = attrNode->nextSibling;
309 if (!element || !oldAttr) {
310 return IXML_INVALID_PARAMETER;
316 IXML_Node* preSib = attrNode->prevSibling;
317 IXML_Node* nextSib = attrNode->nextSibling;
319 preSib->nextSibling = nextSib;
322 nextSib->prevSibling = preSib;
324 if (element->n.firstAttr == attrNode) {
325 element->n.firstAttr = nextSib;
327 attrNode->parentNode = NULL;
328 attrNode->prevSibling = NULL;
329 attrNode->nextSibling = NULL;
333 return IXML_NOT_FOUND_ERR;
341 if (element && tagName) {
345 return returnNodeList;
354 if (!element || !namespaceURI || !localName) {
358 attrNode = element->n.firstAttr;
360 if (attrNode->localName && attrNode->namespaceURI &&
361 strcmp(attrNode->localName, localName) == 0 &&
362 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
364 return attrNode->nodeValue;
366 attrNode = attrNode->nextSibling;
381 if (!element || !namespaceURI || !qualifiedName || !value) {
382 return IXML_INVALID_PARAMETER;
385 return IXML_INVALID_CHARACTER_ERR;
388 newAttrNode.nodeName = strdup(qualifiedName);
389 if (!newAttrNode.nodeName) {
390 return IXML_INSUFFICIENT_MEMORY;
393 if (rc != IXML_SUCCESS) {
399 if ((newAttrNode.prefix && !namespaceURI) ||
400 (newAttrNode.prefix && strcmp(newAttrNode.prefix,
"xml") == 0 &&
401 strcmp(namespaceURI,
"http://www.w3.org/XML/1998/namespace") != 0) ||
402 (strcmp(qualifiedName,
"xmlns") == 0 &&
403 strcmp(namespaceURI,
"http://www.w3.org/2000/xmlns/") != 0)) {
405 return IXML_NAMESPACE_ERR;
408 attrNode = element->n.firstAttr;
410 if (attrNode->localName && attrNode->namespaceURI &&
411 strcmp(attrNode->localName, newAttrNode.localName) == 0 &&
412 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
416 attrNode = attrNode->nextSibling;
419 if (attrNode->prefix) {
421 free(attrNode->prefix);
424 if (newAttrNode.prefix) {
425 attrNode->prefix = strdup(newAttrNode.prefix);
426 if (!attrNode->prefix) {
428 return IXML_INSUFFICIENT_MEMORY;
431 attrNode->prefix = newAttrNode.prefix;
433 if (attrNode->nodeValue) {
434 free(attrNode->nodeValue);
436 attrNode->nodeValue = strdup(value);
437 if (!attrNode->nodeValue) {
438 free(attrNode->prefix);
440 return IXML_INSUFFICIENT_MEMORY;
446 qualifiedName, &newAttr);
447 if (rc != IXML_SUCCESS) {
451 newAttr->n.nodeValue = strdup(value);
452 if (!newAttr->n.nodeValue) {
455 return IXML_INSUFFICIENT_MEMORY;
474 if (!element || !namespaceURI || !localName) {
475 return IXML_INVALID_PARAMETER;
478 attrNode = element->n.firstAttr;
480 if (attrNode->localName &&
481 strcmp(attrNode->localName, localName) == 0 &&
482 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
486 attrNode = attrNode->nextSibling;
490 if (attrNode->nodeValue) {
491 free(attrNode->nodeValue);
492 attrNode->nodeValue = NULL;
504 if (!element || !namespaceURI || !localName) {
508 attrNode = element->n.firstAttr;
510 if (attrNode->localName && attrNode->namespaceURI &&
511 strcmp(attrNode->localName, localName) == 0 &&
512 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
516 attrNode = attrNode->nextSibling;
529 if (!element || !newAttr) {
530 return IXML_INVALID_PARAMETER;
532 if (newAttr->n.ownerDocument != element->n.ownerDocument) {
533 return IXML_WRONG_DOCUMENT_ERR;
535 if (newAttr->ownerElement && newAttr->ownerElement != element) {
536 return IXML_INUSE_ATTRIBUTE_ERR;
539 newAttr->ownerElement = element;
541 attrNode = element->n.firstAttr;
543 if (attrNode->localName && node->localName && attrNode->namespaceURI &&
544 node->namespaceURI &&
545 strcmp(attrNode->localName, node->localName) == 0 &&
546 strcmp(attrNode->namespaceURI, node->namespaceURI) == 0) {
550 attrNode = attrNode->nextSibling;
554 IXML_Node* preSib = attrNode->prevSibling;
555 IXML_Node* nextSib = attrNode->nextSibling;
557 preSib->nextSibling = node;
560 nextSib->prevSibling = node;
562 if (element->n.firstAttr == attrNode) {
563 element->n.firstAttr = node;
569 if (element->n.firstAttr) {
571 IXML_Node* prevAttr = element->n.firstAttr;
572 IXML_Node* nextAttr = prevAttr->nextSibling;
575 nextAttr = prevAttr->nextSibling;
577 prevAttr->nextSibling = node;
580 element->n.firstAttr = node;
581 node->prevSibling = NULL;
582 node->nextSibling = NULL;
598 if (element && namespaceURI && localName) {
609 if (!element || !name) {
613 attrNode = element->n.firstAttr;
615 if (attrNode->nodeName && strcmp(attrNode->nodeName, name) == 0) {
618 attrNode = attrNode->nextSibling;
629 if (!element || !namespaceURI || !localName) {
633 attrNode = element->n.firstAttr;
635 if (attrNode->localName && attrNode->namespaceURI &&
636 strcmp(attrNode->localName, localName) == 0 &&
637 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
640 attrNode = attrNode->nextSibling;
int ixmlElement_setTagName(IXML_Element *element, const char *tagName)
Set the given element's tagName.
static IXML_Node * ixmlElement_findAttributeNode(IXML_Element *element, IXML_Attr *oldAttr)
Find a attribute node whose contents are the same as the oldAttr.
Data structure common to all types of nodes.
Data structure representing an Attribute node.
Data structure representing a list of nodes.
Data structure representing an Element node.
Data structure representing the DOM Document.
const DOMString ixmlElement_getAttributeNS(IXML_Element *element, const DOMString namespaceURI, const DOMString localName)
Retrieves an attribute value using the local name and namespace URI.
int ixmlElement_setAttribute(IXML_Element *element, const DOMString name, const DOMString value)
Adds a new attribute to an Element.
PUPNP_Api void ixmlAttr_free(IXML_Attr *attrNode)
Frees an Attr node.
int ixmlElement_removeAttribute(IXML_Element *element, const DOMString name)
Removes an attribute value by name. The attribute node is not removed.
int ixmlElement_hasAttribute(IXML_Element *element, const DOMString name)
Queries whether the Element has an attribute with the given name or a default value.
PUPNP_Api int ixmlDocument_createAttributeNSEx(IXML_Document *doc, const DOMString namespaceURI, const DOMString qualifiedName, IXML_Attr **attrNode)
Creates a new Attr node with the given qualified name and namespace URI.
PUPNP_Api int ixmlDocument_createAttributeEx(IXML_Document *doc, const DOMString name, IXML_Attr **attrNode)
Creates a new Attr node with the given name.
#define DOMString
The type of DOM strings.
PUPNP_Api void ixmlNode_free(IXML_Node *nodeptr)
Frees a Node and all Nodes in its subtree.
IXML_Attr * ixmlElement_getAttributeNode(IXML_Element *element, const DOMString name)
Retrieves an attribute node by name. See ixmlElement_getAttributeNodeNS to retrieve an attribute node...
void ixmlElement_init(IXML_Element *element)
Initializes a IXML_Element node.
const DOMString ixmlElement_getAttribute(IXML_Element *element, const DOMString name)
Retrieves an attribute of an Element by name.
int ixmlElement_removeAttributeNode(IXML_Element *element, IXML_Attr *oldAttr, IXML_Attr **rtAttr)
Removes the specified attribute node from an Element.
IXML_Attr * ixmlElement_getAttributeNodeNS(IXML_Element *element, const DOMString namespaceURI, const DOMString localName)
Retrieves an Attr node by local name and namespace URI.
int ixmlElement_setAttributeNode(IXML_Element *element, IXML_Attr *newAttr, IXML_Attr **rtAttr)
Adds a new attribute node to an Element.
void ixmlElement_free(IXML_Element *element)
Frees the given Element and any subtree of the Element.
int ixmlElement_setAttributeNodeNS(IXML_Element *element, IXML_Attr *newAttr, IXML_Attr **rtAttr)
Adds a new attribute node to the element node specified.
int ixmlElement_setAttributeNS(IXML_Element *element, const DOMString namespaceURI, const DOMString qualifiedName, const DOMString value)
Adds a new attribute to an Element using the local qualified name and namespace URI.
int ixmlElement_removeAttributeNS(IXML_Element *element, const DOMString namespaceURI, const DOMString localName)
Removes an attribute using the namespace URI and local name.
int ixmlElement_hasAttributeNS(IXML_Element *element, const DOMString namespaceURI, const DOMString localName)
Queries whether the Element has an attribute with the given local name and namespace URI or has a def...
IXML_NodeList * ixmlElement_getElementsByTagNameNS(IXML_Element *element, const DOMString namespaceURI, const DOMString localName)
Returns a NodeList of all descendant Elements with a given local name and namespace in the order in w...
const DOMString ixmlElement_getTagName(IXML_Element *element)
Returns the name of the tag as a constant string.
IXML_NodeList * ixmlElement_getElementsByTagName(IXML_Element *element, const DOMString tagName)
Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are e...
void ixmlNode_getElementsByTagName(IXML_Node *n, const char *tagname, IXML_NodeList **list)
Returns a nodeList of all descendant Elements with a given tagName, in the order in which they are en...
void ixmlNode_init(IXML_Node *nodeptr)
Intializes a node.
void Parser_freeNodeContent(IXML_Node *IXML_Nodeptr)
Fees a node contents.
int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr)
Set the node prefix and localName as defined by the nodeName in the form of ns:name.
int ixmlNode_compare(const IXML_Node *srcNode, const IXML_Node *destNode)
Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignore...
int Parser_isValidXmlName(const DOMString name)
Check to see whether name is a valid xml name.
void ixmlNode_getElementsByTagNameNS(IXML_Node *n, const char *namespaceURI, const char *localName, IXML_NodeList **list)
Returns a nodeList of all the descendant Elements with a given local name and namespace URI in the or...