PutElement Method

Writes a simple XML element with a value.

Syntax

ANSI (Cross Platform)
int PutElement(const char* lpszName, const char* lpszNamespaceURI, const char* lpszValue);

Unicode (Windows)
INT PutElement(LPCWSTR lpszName, LPCWSTR lpszNamespaceURI, LPCWSTR lpszValue);
- (void)putElement:(NSString*)name :(NSString*)namespaceURI :(NSString*)value;
#define MID_XML_PUTELEMENT 13

IPWORKS_EXTERNAL int IPWORKS_CALL IPWorks_XML_Do(void *lpObj, int methid, int cparam, void *param[], int cbparam[], int64 *lpllVal);

Remarks

Writes a simple XML element with no attributes and the specified value between the opening and closing tags.

If Name is a local name without a prefix, the class will automatically introduce a new xmlns="NamespaceURI" attribute if necessary.

If Name is in the form prefix:local, then class will automatically introduce a new xmlns:prefix="NamespaceURI" as necessary.

When calling PutElement or StartElement, if a NamespaceURI is not specified an empty namespace will be defined for the element. If a namespace should be associated with the element, a NamespaceURI value must be provided. When creating the XML, the class will determine if the namespace already exists to avoid duplicate definitions of the same namespace. For example, to create this XML:

<book xmlns='urn:loc.gov:books'
      xmlns:isbn='urn:ISBN:0-395-36341-6'>
    <title>Cheaper by the Dozen</title>
    <isbn:number>1568491379</isbn:number>
</book>
Use the code:
xml.StartElement("book", "urn:loc.gov:books");
xml.PutAttr("xmlns:isbn", "", "urn:ISBN:0-395-36341-6");
xml.PutElement("title", "urn:loc.gov:books", "Cheaper by the Dozen");
xml.PutElement("isbn:number", "urn:ISBN:0-395-36341-6", "1568491379");
xmlw.Close();
In the above example the "title" element uses the default namespace "urn:loc.gov:books" and the "number" element uses the "urn:ISBN:0-395-36341-6" namespace as defined for the "isbn" prefix.

Error Handling (C++)

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks 2020 C++ Edition - Version 20.0 [Build 8307]