this is my XML data file:
<?xml version = "1.0"?>
<contact-info>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</contact-info>
and this is my flutter code:
Future _xml() async {
http.Response response = await http.get(Uri.parse(url));
XmlData = XmlDocument.parse(response.body);
final wantData = XmlData!.findAllElements('contact-info');
}
please how i can get the value TutorialsPoint from my xml file
CodePudding user response:
Use the xml package
import 'package:xml/xml.dart' as xml;
var xmldata='<?xml version = "1.0"?>
<contact-info>
<name>Tanmay Patil</name>
<company>TutorialsPoint</company>
<phone>(011) 123-4567</phone>
</contact-info>';
void main() {
var contact = xml.parse(xmldata);
print(contact.findAllElements('phone'));
}