Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   Как распарсить такой XML ! (http://www.flasher.ru/forum/showthread.php?t=133510)

_moscow 07.12.2009 14:51

Как распарсить такой XML !
 
Всем привет !

Вот есть XML

Код AS3:

 
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet">
  <o:OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"/>
  <x:ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"/>
  <Worksheet Name="goods">
    <Table>
      <Row>
        <Cell>
          <Data Type="String">name</Data>
        </Cell>
        <Cell>
          <Data Type="String">name</Data>
        </Cell>
      </Row>
    </Table>
  </Worksheet>
</Workbook>


Как вытащить значения <Data></Data> ?

random13 07.12.2009 15:06

а в чем собственно проблема, стандартного класса не достаточно?

_moscow 07.12.2009 15:09

Цитата:

Сообщение от random13 (Сообщение 870769)
а в чем собственно проблема, стандартного класса не достаточно?


Стандартно не получается - всроде все перепробывал !

Juice_Green 07.12.2009 15:17

вам надо как-то избавится от
Код:

<o:OfficeDocumentSettings xmlns="urn:schemas-microsoft-comfficeffice"/>
<x:ExcelWorkbook xmlns="urn:schemas-microsoft-comffice:excel"/>

ругается на них

pashadoba 07.12.2009 15:26

Код AS3:

var s:String = 'твой xml'
s = s.substr(s.indexOf('<Worksheet Name="goods">'), s.indexOf('</Workbook>'));
var _xml:XML = new XML(s);
for(var i:int = 0 ; i <_xml.Table.*.Cell.length()-1; i++)
    trace(_xml.Table.*.Cell.Data[i]);


bicubic_bublic 07.12.2009 15:31

s = s.substring(s.indexOf('<Worksheet Name="goods">'), s.indexOf('</Workbook>') + '</Workbook>'.length);

pashadoba 07.12.2009 15:34

Цитата:

Сообщение от bicubic_bublic (Сообщение 870786)
s = s.substring(s.indexOf('<Worksheet Name="goods">'), s.indexOf('</Workbook>') + '</Workbook>'.length);

нет... надо от начала <Worksheet> и до начала '</Workbook>

ели как у тебя то s.indexOf('</Worksheet>') + '</Worksheet>'.length);

etc 07.12.2009 18:21

Код AS3:

var xml:XML = <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet">
  <o:OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"/>
  <x:ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"/>
  <Worksheet Name="goods">
    <Table>
      <Row>
        <Cell>
          <Data Type="String">name</Data>
        </Cell>
        <Cell>
          <Data Type="String">name</Data>
        </Cell>
      </Row>
    </Table>
  </Worksheet>
</Workbook>;
var ns:Namespace = xml.namespace();
trace(xml..ns::Data.toXMLString());



Часовой пояс GMT +4, время: 02:55.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.