44 if (element != NULL) {
50 if (element != NULL) {
51 return element->tagName;
58 int rc = IXML_SUCCESS;
60 assert(element != NULL && tagName != NULL);
62 if (element == NULL || tagName == NULL) {
66 if (element->tagName != NULL) {
67 free(element->tagName);
69 element->tagName = strdup(tagName);
70 if (element->tagName == NULL) {
71 rc = IXML_INSUFFICIENT_MEMORY;
81 if (element == NULL || name == NULL) {
85 attrNode = element->n.firstAttr;
86 while (attrNode != NULL) {
87 if (strcmp(attrNode->nodeName, name) == 0) {
88 return attrNode->nodeValue;
90 attrNode = attrNode->nextSibling;
101 int errCode = IXML_SUCCESS;
103 if (element == NULL || name == NULL || value == NULL) {
104 errCode = IXML_INVALID_PARAMETER;
109 errCode = IXML_INVALID_CHARACTER_ERR;
113 attrNode = element->n.firstAttr;
114 while (attrNode != NULL) {
115 if (strcmp(attrNode->nodeName, name) == 0) {
119 attrNode = attrNode->nextSibling;
123 if (attrNode == NULL) {
126 (
IXML_Document*)element->n.ownerDocument, name, &newAttrNode);
127 if (errCode != IXML_SUCCESS) {
132 attrNode->nodeValue = strdup(value);
133 if (attrNode->nodeValue == NULL) {
135 errCode = IXML_INSUFFICIENT_MEMORY;
140 if (errCode != IXML_SUCCESS) {
145 if (attrNode->nodeValue != NULL) {
147 free(attrNode->nodeValue);
149 attrNode->nodeValue = strdup(value);
150 if (attrNode->nodeValue == NULL) {
151 errCode = IXML_INSUFFICIENT_MEMORY;
162 if (element == NULL || name == NULL) {
163 return IXML_INVALID_PARAMETER;
166 attrNode = element->n.firstAttr;
167 while (attrNode != NULL) {
168 if (strcmp(attrNode->nodeName, name) == 0) {
172 attrNode = attrNode->nextSibling;
175 if (attrNode != NULL) {
177 if (attrNode->nodeValue != NULL) {
178 free(attrNode->nodeValue);
179 attrNode->nodeValue = NULL;
190 if (element == NULL || name == NULL) {
194 attrNode = element->n.firstAttr;
195 while (attrNode != NULL) {
196 if (strcmp(attrNode->nodeName, name) == 0) {
200 attrNode = attrNode->nextSibling;
216 if (!element || !newAttr)
217 return IXML_INVALID_PARAMETER;
218 if (newAttr->n.ownerDocument != element->n.ownerDocument)
219 return IXML_WRONG_DOCUMENT_ERR;
220 if (newAttr->ownerElement)
221 return IXML_INUSE_ATTRIBUTE_ERR;
222 newAttr->ownerElement = element;
224 attrNode = element->n.firstAttr;
226 if (!strcmp(attrNode->nodeName, node->nodeName))
230 attrNode = attrNode->nextSibling;
234 preSib = attrNode->prevSibling;
235 nextSib = attrNode->nextSibling;
237 preSib->nextSibling = node;
239 nextSib->prevSibling = node;
240 if (element->n.firstAttr == attrNode)
241 element->n.firstAttr = node;
248 if (element->n.firstAttr) {
249 prevAttr = element->n.firstAttr;
250 nextAttr = prevAttr->nextSibling;
253 nextAttr = prevAttr->nextSibling;
255 prevAttr->nextSibling = node;
256 node->prevSibling = prevAttr;
259 element->n.firstAttr = node;
260 node->prevSibling = NULL;
261 node->nextSibling = NULL;
284 assert(element != NULL && oldAttr != NULL);
286 attrNode = element->n.firstAttr;
287 while (attrNode != NULL) {
294 attrNode = attrNode->nextSibling;
307 if (element == NULL || oldAttr == NULL) {
308 return IXML_INVALID_PARAMETER;
312 if (attrNode != NULL) {
314 preSib = attrNode->prevSibling;
315 nextSib = attrNode->nextSibling;
316 if (preSib != NULL) {
317 preSib->nextSibling = nextSib;
319 if (nextSib != NULL) {
320 nextSib->prevSibling = preSib;
322 if (element->n.firstAttr == attrNode) {
323 element->n.firstAttr = nextSib;
325 attrNode->parentNode = NULL;
326 attrNode->prevSibling = NULL;
327 attrNode->nextSibling = NULL;
331 return IXML_NOT_FOUND_ERR;
339 if (element != NULL && tagName != NULL) {
343 return returnNodeList;
352 if (element == NULL || namespaceURI == NULL || localName == NULL) {
356 attrNode = element->n.firstAttr;
357 while (attrNode != NULL) {
358 if (strcmp(attrNode->localName, localName) == 0 &&
359 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
361 return attrNode->nodeValue;
363 attrNode = attrNode->nextSibling;
379 if (element == NULL || namespaceURI == NULL || qualifiedName == NULL ||
381 return IXML_INVALID_PARAMETER;
385 return IXML_INVALID_CHARACTER_ERR;
389 newAttrNode.nodeName = strdup(qualifiedName);
390 if (newAttrNode.nodeName == NULL) {
391 return IXML_INSUFFICIENT_MEMORY;
395 if (rc != IXML_SUCCESS) {
401 if ((newAttrNode.prefix != NULL && namespaceURI == NULL) ||
402 (newAttrNode.prefix != NULL && strcmp(newAttrNode.prefix,
"xml") == 0 &&
403 strcmp(namespaceURI,
"http://www.w3.org/XML/1998/namespace") != 0) ||
404 (strcmp(qualifiedName,
"xmlns") == 0 &&
405 strcmp(namespaceURI,
"http://www.w3.org/2000/xmlns/") != 0)) {
407 return IXML_NAMESPACE_ERR;
410 attrNode = element->n.firstAttr;
411 while (attrNode != NULL) {
412 if (strcmp(attrNode->localName, newAttrNode.localName) == 0 &&
413 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
417 attrNode = attrNode->nextSibling;
420 if (attrNode != NULL) {
421 if (attrNode->prefix != NULL) {
423 free(attrNode->prefix);
426 if (newAttrNode.prefix != NULL) {
427 attrNode->prefix = strdup(newAttrNode.prefix);
428 if (attrNode->prefix == NULL) {
430 return IXML_INSUFFICIENT_MEMORY;
433 attrNode->prefix = newAttrNode.prefix;
435 if (attrNode->nodeValue != NULL) {
436 free(attrNode->nodeValue);
438 attrNode->nodeValue = strdup(value);
439 if (attrNode->nodeValue == NULL) {
440 free(attrNode->prefix);
442 return IXML_INSUFFICIENT_MEMORY;
448 qualifiedName, &newAttr);
449 if (rc != IXML_SUCCESS) {
453 newAttr->n.nodeValue = strdup(value);
454 if (newAttr->n.nodeValue == NULL) {
457 return IXML_INSUFFICIENT_MEMORY;
476 if (element == NULL || namespaceURI == NULL || localName == NULL) {
477 return IXML_INVALID_PARAMETER;
480 attrNode = element->n.firstAttr;
481 while (attrNode != NULL) {
482 if (strcmp(attrNode->localName, localName) == 0 &&
483 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
487 attrNode = attrNode->nextSibling;
490 if (attrNode != NULL) {
492 if (attrNode->nodeValue != NULL) {
493 free(attrNode->nodeValue);
494 attrNode->nodeValue = NULL;
506 if (element == NULL || namespaceURI == NULL || localName == NULL) {
510 attrNode = element->n.firstAttr;
511 while (attrNode != NULL) {
512 if (strcmp(attrNode->localName, localName) == 0 &&
513 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
517 attrNode = attrNode->nextSibling;
535 if (element == NULL || newAttr == NULL) {
536 return IXML_INVALID_PARAMETER;
539 if (newAttr->n.ownerDocument != element->n.ownerDocument) {
540 return IXML_WRONG_DOCUMENT_ERR;
543 if (newAttr->ownerElement != NULL && newAttr->ownerElement != element) {
544 return IXML_INUSE_ATTRIBUTE_ERR;
547 newAttr->ownerElement = element;
549 attrNode = element->n.firstAttr;
550 while (attrNode != NULL) {
551 if (strcmp(attrNode->localName, node->localName) == 0 &&
552 strcmp(attrNode->namespaceURI, node->namespaceURI) == 0) {
556 attrNode = attrNode->nextSibling;
559 if (attrNode != NULL) {
561 preSib = attrNode->prevSibling;
562 nextSib = attrNode->nextSibling;
563 if (preSib != NULL) {
564 preSib->nextSibling = node;
566 if (nextSib != NULL) {
567 nextSib->prevSibling = node;
569 if (element->n.firstAttr == attrNode) {
570 element->n.firstAttr = node;
576 if (element->n.firstAttr != NULL) {
578 prevAttr = element->n.firstAttr;
579 nextAttr = prevAttr->nextSibling;
580 while (nextAttr != NULL) {
582 nextAttr = prevAttr->nextSibling;
584 prevAttr->nextSibling = node;
587 element->n.firstAttr = node;
588 node->prevSibling = NULL;
589 node->nextSibling = NULL;
591 if (rtAttr != NULL) {
605 if (element != NULL && namespaceURI != NULL && localName != NULL) {
616 if (element == NULL || name == NULL) {
620 attrNode = element->n.firstAttr;
621 while (attrNode != NULL) {
622 if (strcmp(attrNode->nodeName, name) == 0) {
625 attrNode = attrNode->nextSibling;
637 if (element == NULL || namespaceURI == NULL || localName == NULL) {
641 attrNode = element->n.firstAttr;
642 while (attrNode != NULL) {
643 if (strcmp(attrNode->localName, localName) == 0 &&
644 strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
647 attrNode = attrNode->nextSibling;
655 if (element != NULL) {
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 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...
int ixmlNode_compare(IXML_Node *srcNode, IXML_Node *destNode)
Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignore...
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 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...