import ballerina/io;
import ballerina/lang.'xml;
public function main() returns error? {
xml x = xml `<book>Hamlet</book><book>Macbeth</book>`;
xml mappedXml = x.map(function (xml xmlContent) returns xml =>
xml `<book kind="play">${xmlContent.children()}</book>`
);
string y = x.getItemType();
io:println(y);
}
This does not compile and gives the error of
ERROR [main.bal:(11:18,11:29)] undefined function 'getItemType' in type 'xml'
error: compilation contains errors
I have tried many forms of xmls to do this, but any method i did not find the xml getItemType. Anyone knows the answer?
I am expecting how to compile, this code and how to use getItemType() method in order to work on the my project on developing the an intergration for the ballerina language.
For the ballerina xml type we don't have a method called
getItemType
. Thats why you are getting this compile time error. If you want to access the specific segments of this xml sequence you can do as below example.For further reference you can find these BBEs expaling accesing and navigating on xml values. XML value access
XML value navigation