Parsing XML files and saving in a database

From NSB App Studio
Jump to navigation Jump to search

In this sample you can parse an XML-File with AJAX and save the Data in storage


What you need?

  • a php File (xmlparser.php)
  • a XML-File (xml-File saved with your data)
  • A Button in your AppStduio (btnSave)


My Datas

xmlparser.php

<?php
header('Access-Control-Allow-Origin: *');
echo file_get_contents($_GET['urlToGet']);
?>

XML-File

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<menu.xml>
<row>
    <Menue>1</Menue>
    <Scout></Scout>
    <Text_D>Shake</Text_D>
    <Text_C>Shake</Text_C>
    <Beschreibung_D></Beschreibung_D>
    <Beschreibung_C></Beschreibung_C>
    <Sort>31</Sort>
    <Gruppe>H</Gruppe>
    <Preis3>0</Preis3>
    <WarenGruppe>41</WarenGruppe>
    <SabuSabu>1</SabuSabu>
    <IpadZeitZone>0</IpadZeitZone>
</row>
<row>
    <Menue>2</Menue>
    <Scout></Scout>
    <Text_D>Maguro</Text_D>
    <Text_C>Maguro</Text_C>
    <Beschreibung_D></Beschreibung_D>
    <Beschreibung_C></Beschreibung_C>
    <Sort>31</Sort>
    <Gruppe>H</Gruppe>
    <Preis3>0</Preis3>
    <WarenGruppe>41</WarenGruppe>
    <SabuSabu>1</SabuSabu>
    <IpadZeitZone>2</IpadZeitZone>
</row>
<row>
    <Menue>3</Menue>
    <Scout></Scout>
    <Text_D>Ika Nigiri Lachs</Text_D>
    <Text_C>Ika Nigiri Lachs</Text_C>
    <Beschreibung_D></Beschreibung_D>
    <Beschreibung_C></Beschreibung_C>
    <Sort>31</Sort>
    <Gruppe>H</Gruppe>
    <Preis3>0</Preis3>
    <WarenGruppe>41</WarenGruppe>
    <SabuSabu>1</SabuSabu>
    <IpadZeitZone>0</IpadZeitZone>
</row>


AppStudio Code