Bundle XML parsing and building library. XmlParser reads XML into an XmlElement tree with attribute and child-node navigation; XmlBuilder constructs XML documents. Compile with -lib xml.
XmlAttribute
Represents an XML attribute
Operations
GetDecodedValue #
Gets the attribute value with XML entity references decoded (< > & " ' and numeric references).
method : public : GetDecodedValue() ~ StringReturn
| Type | Description |
|---|---|
| String | decoded attribute value |
Example
parser := XmlParser->New("<a title=\"5 < 6\"/>");
if(parser->Parse()) {
attrib := parser->GetRoot()->GetAttribute("title");
attrib->GetDecodedValue()->PrintLine(); # 5 < 6
};GetName #
Gets the name of the attribute
method : public : GetName() ~ StringReturn
| Type | Description |
|---|---|
| String | attribute name |
Example
parser := XmlParser->New("<item id=\"7\"/>");
if(parser->Parse()) {
attrib := parser->GetRoot()->GetAttribute("id");
attrib->GetName()->PrintLine();
};GetNamespace #
Gets the attribute namespace
method : public : GetNamespace() ~ StringReturn
| Type | Description |
|---|---|
| String | attribute namespace |
Example
attrib := XmlAttribute->New("xml:lang", "en");
attrib->GetNamespace()->PrintLine();GetValue #
Gets the attribute value as it appeared in the source: entity references such as & are NOT decoded. Use GetDecodedValue for the decoded text.
method : public : GetValue() ~ StringReturn
| Type | Description |
|---|---|
| String | raw attribute value |
Example
parser := XmlParser->New("<img src=\"photo.png\"/>");
if(parser->Parse()) {
attrib := parser->GetRoot()->GetAttribute("src");
attrib->GetValue()->PrintLine();
};New # constructor
Constructor
New(name:String, value:String)Parameters
| Name | Type | Description |
|---|---|---|
| name | String | attribute name |
| value | String | attribute value |
SetName #
Sets the attribute name
method : public : SetName(name:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| name | String | attribute name |
Example
attrib := XmlAttribute->New("class", "widget");
attrib->SetName("id");
attrib->GetName()->PrintLine();