Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

CFXMLNodeMBS class

Super class: CFObjectMBS

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class CoreFoundation MBS MacCF Plugin 3.4 Yes No No Yes, macOS only No
Function: A class for a xml node.
Example:
dim documentinfo as new CFXMLDocumentInfoMBS
dim docnode as new CFXMLNodeMBS
dim instructionNode as new CFXMLNodeMBS
dim xmldocument as new CFTreeMBS
dim instructionTree as new CFTreeMBS
dim instructionInfo as new CFXMLProcessingInstructionInfoMBS
dim personInfo as new CFXMLElementInfoMBS
dim personNode as new CFXMLNodeMBS
dim personTree as new CFTreeMBS
dim nameInfo as new CFXMLElementInfoMBS
dim nameNode as new CFXMLNodeMBS
dim nameTree as new CFTreeMBS
dim nameTextNode as new CFXMLNodeMBS
dim nameTextTree as new CFTreeMBS
dim nameTextNode2 as new CFXMLNodeMBS
dim nameTextTree2 as new CFTreeMBS
dim person as CFStringMBS

const kCFStringEncodingUTF8=&h08000100

// create a document node
documentinfo.SourceURL=nil
documentinfo.CFStringEncoding=kCFStringEncodingUTF8

docnode.CreateDocument(documentinfo)

xmldocument.CreateWithXMLNode docNode

// Instruction Tag

instructionInfo.DataString=NewCFStringMBS("version=""1.0"" encoding=""utf-8"" ")
instructionNode.CreateProcessInstruction(NewCFStringMBS("xml"),instructionInfo)
instructionTree.CreateWithXMLNode(instructionNode)

// root element

personInfo.XMLAttributes=nil
personInfo.AttributeOrder=nil
personInfo.IsEmpty=false

person=NewCFStringMBS("person")
personNode.CreateElement person, personInfo
personTree.CreateWithXMLNode personNode

nameInfo.XMLAttributes=nil
nameInfo.AttributeOrder=nil
nameInfo.IsEmpty=false

namenode.CreateElement NewCFStringMBS("name"), nameInfo
nameTree.CreateWithXMLNode nameNode
personTree.AppendChild nameTree

nameTextNode.CreateText NewCFStringMBS("Apple")
nameTextTree.CreateWithXMLNode nameTextNode
nameTree.AppendChild nameTextTree

nameTextNode2.CreateText NewCFStringMBS("Orange")
nameTextTree2.CreateWithXMLNode nameTextNode2
nameTree.AppendChild nameTextTree2

CFShowMBS(xmldocument)

xmldocument.AppendChild instructionTree
xmldocument.AppendChild personTree

MsgBox xmldocument.XMLData.str

// shows "<?xml version="1.0" encoding="utf-8" ?><person><name>AppleOrange</name></person>"
Notes:
An CFXMLNode describes an individual XML construct - like a tag, or a comment, or a string of character data. Each CFXMLNode contains 3 main pieces of information - the node's type, the data string, and a pointer to an additional data structure. The node's type ID is an enum value of type CFXMLNodeTypeCode. The data string is always a CFStringRef; the meaning of the string is dependent on the node's type ID. The format of the additional data is also dependent on the node's type; in general, there is a custom structure for each type that requires additional data. See below for the mapping from type ID to meaning of the data string and structure of the additional data.

Type codes for the different possible XML nodes; this list may grow:

Constant namevalueMeaning of Data stringAdditional information
kCFXMLNodeTypeDocument1<currently unused>CFXMLDocumentInfoMBS
kCFXMLNodeTypeElement2tag nameCFXMLElementInfoMBS
kCFXMLNodeTypeAttribute3<currently unused><currently unused>
kCFXMLNodeTypeProcessingInstruction4name of the targetCFXMLProcessingInstructionInfoMBS
kCFXMLNodeTypeComment5text of the commentnil
kCFXMLNodeTypeText6the text's contentsnil
kCFXMLNodeTypeCDATASection7text of the CDATAnil
kCFXMLNodeTypeDocumentFragment8<currently unused><currently unused>
kCFXMLNodeTypeEntity9name of the entityCFXMLEntityInfoMBS
kCFXMLNodeTypeEntityReference10name of the referenced entityCFXMLEntityReferenceInfoMBS
kCFXMLNodeTypeDocumentType11name given as top-level elementCFXMLDocumentTypeInfoMBS
kCFXMLNodeTypeWhitespace12text of the whitespacenil
kCFXMLNodeTypeNotation13notation nameCFXMLNotationInfoMBS
kCFXMLNodeTypeElementTypeDeclaration14tag nameCFXMLElementTypeDeclarationInfoMBS
kCFXMLNodeTypeAttributeListDeclaration15tag nameCFXMLAttributeListDeclarationInfoMBS
Subclass of the CFObjectMBS class.

Feedback, Comments & Corrections

Super class CFObjectMBS

This class has no sub classes.

Some methods using this class:

Some events for this class:

Some examples which use this class:


The items on this page are in the following plugins: MBS MacCF Plugin.


CFXMLExternalIDMBS   -   CFXMLNotationInfoMBS




Links
MBS Xojo tutorial videos