Issue
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
Solution
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'));
}
Answered By - Ashutosh singh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.