Home > Net >  how do i read xml file value
how do i read xml file value

Time:03-25

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'));
}
  • Related