PHP, XML okuyucusu alan türleri

0 Cevap php

Ben bu formatta bir xml dosyası vardır:

<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:o="urn:schemas-microsoft-com:office:office">
<Styles>
<Style ss:Name="Normal" ss:ID="Default">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:Name="FormatedNumberBorderPatern" ss:ID="FormattedNumberBorderPatern">
<Alignment ss:WrapText="1" ss:Vertical="Center"/>
<NumberFormat/>
<Borders>
<Border ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Bottom"/>
<Border ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Left"/>
<Border ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Right"/>
<Border ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Top"/>
</Borders>
</Style>
<Style ss:ID="s40">
<Alignment ss:Vertical="Bottom"/>
<Font ss:Bold="1" ss:Color="#7A2A29" ss:Size="12" x:Family="Swiss" x:CharSet="204"/>
</Style>
<Style ss:ID="s25">
<Alignment ss:WrapText="1" ss:Vertical="Center" ss:Horizontal="Center"/>
<Borders>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Bottom"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Left"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Right"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Top"/>
</Borders>
<Font ss:Bold="1" ss:FontName="Arial Unicode MS"/>
</Style>
<Style ss:ID="m155750108">
<Alignment ss:WrapText="1" ss:Vertical="Bottom"/>
<Borders>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Bottom"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Left"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Right"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Top"/>
</Borders>
<Font ss:FontName="Arial Unicode MS"/>
</Style>
<Style ss:ID="empty">
<Alignment ss:Horizontal="Right"/>
<Borders>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Bottom"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Left"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Right"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Top"/>
</Borders>
<Font ss:Bold="1" ss:FontName="Arial Unicode MS"/>
</Style>
<Style ss:ID="s30">
<Alignment ss:WrapText="1" ss:Vertical="Center" ss:Horizontal="Left"/>
<Borders>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Bottom"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Left"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Right"/>
<Border ss:Color="#000000" ss:Weight="1" ss:LineStyle="Continuous" ss:Position="Top"/>
</Borders>
<Font ss:FontName="Arial Unicode MS"/>
</Style>
</Styles>
<Worksheet ss:Name="Information">
<Table border="1">
<Column ss:Span="1" ss:Width="192"/>
<Row ss:Height="31.5" ss:AutoFitHeight="0">
<Cell ss:StyleID="s40">
<Data ss:Type="String">Обменни курсове за 29.10.2010</Data>
</Cell>
</Row>
<Row/>
<Row>
<Cell ss:StyleID="s25">
<Data ss:Type="String">Валута</Data>
</Cell>
<Cell ss:StyleID="s25">
<Data ss:Type="String">Код</Data>
</Cell>
<Cell ss:StyleID="s25">
<Data ss:Type="String">За единици валута</Data>
</Cell>
<Cell ss:StyleID="s25">
<Data ss:Type="String">Лева (BGN)</Data>
</Cell>
<Cell ss:StyleID="s25">
<Data ss:Type="String">Обратен курс за 1 лев</Data>
</Cell>
</Row>
<Row>
<Cell ss:StyleID="s30">
<Data ss:Type="String">Австралийски долар</Data>
</Cell>
<Cell ss:StyleID="s30">
<Data ss:Type="String">AUD</Data>
</Cell>
<Cell ss:StyleID="FormattedNumberBorderPatern">
<Data ss:Type="Number">1</Data>
</Cell>
<Cell ss:StyleID="FormattedNumberBorderPatern">
<Data ss:Type="Number">1.37579</Data>
</Cell>
<Cell ss:StyleID="FormattedNumberBorderPatern">
<Data ss:Type="Number">0.726855</Data>
</Cell>
</Row>

..and so on. I only need to pull out data after this line:

<Cell ss:StyleID="s30">

Bu xml bir bankadan (döviz bilgileri) dışarı çekilir. İlk alan, Bulgarca para adıdır ikinci kodu (bir örneğin USD), üçüncü dördüncü para biriminin değeri, bir Bulgar Levası (ile satın alabilirsiniz ne kadar para beşinci, olduğunu, miktarı BGN) bizim para.

I want to create a currency converter but the formatting of the XML confuses me. Can someone tell me how I can pull the information on all of the currencies out? I need these fields in a table:

<Data ss:Type="String">Австралийски долар</Data>
<Data ss:Type="String">AUD</Data>
<Data ss:Type="Number">1</Data>
<Data ss:Type="Number">1.37579</Data>
<Data ss:Type="Number">0.726855</Data>

These lines repeat (along with the cell and row tags) for all of the currencies in the xml file. Could you please give me an example for a single currency? How do I address the data in these fields?

0 Cevap