Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Tiago Campos

Ler dados do XML

Recommended Posts

Boa tarde..

 

Galera estou com um problema, tenho um arquivo XML. Preciso ler e colocar em uma grid.

 

No GridView ele só preenche com o teg q começa com <hotel ..... a grid le isso comu uma tabela e nao consegue exandir o xml e saber q tem mais teg diferentes dela. olhe o exemplo:

 

xml:

 

- <Hotel hotelId="1200737" provider="localTgsProvider" name="Mercure Jardins - DEMO" address="DEMO - Alameda Itu, 1151 Sao Paulo Sao Paulo 01421-001" category="Deluxe Supreme" bestVal="0" thumb="http://image1.urlforimages.com/1200737/Mercure-Jardins-Front_Thumbnailed.jpg" starsLevel="5" minAverPrice="81.79" desc="DEMO - The Mercure Sao Paulo Jardins hotel is located in the centre of the main commercial and tourist center of Sao Paulo, close to the major financial center of the town. This 20 storey-hotel is an excellent choice for both leisure and business trips." location="Sao Paulo,SP,BR" currency="USD" brandId="0" brandName="">

- <RoomType productId="1200737;1605797;63290" name="Standard" nights="5" startDate="2008-01-15T03:00:00-02:00" isAvailable="true" roomId="3" hotelRoomTypeId="1605797">

<Avail offset="0" status="true" />

<Avail offset="1" status="true" />

<Avail offset="2" status="true" />

<Avail offset="3" status="true" />

<Avail offset="4" status="true" />

- <Occup occupId="1200737;1605797;63290;2;1;0" maxAdult="2" maxChild="0" price="408.95" tax="19.45" avrNightPrice="81.79">

<Board bbId="2" name="Café da Manhã Americano" price="0" default="true" />

<Room seqNum="1" adultNum="1" childNum="0" />

<Price offset="0" value="81.79" />

<Price offset="1" value="81.79" />

<Price offset="2" value="81.79" />

<Price offset="3" value="81.79" />

<Price offset="4" value="81.79" />

</Occup>

</RoomType>

</Hotel>

- <Hotel hotelId="17147" provider="localTgsProvider" name="Sofitel São Paulo - DEMO" address="DEMO - Rua Sena Madureira, 1355 Sao Paulo Sao Paulo 04021051" category="Deluxe Supreme" bestVal="0" thumb="http://image1.urlforimages.com/17147/SofitelSaoPaulo-front_Thumbnailed.jpg" starsLevel="5" minAverPrice="169.11" desc="O Sofitel São Paulo se diferencia pela arte de acolher e o prazer de receber bem. São 219 apartamentos e suítes decorados com requinte e sofisticação distribuidos em 19 andares. Elegantes e funcionais, todos são equipados" location="Sao Paulo,SP,BR" currency="USD" brandId="237" brandName="Sofitel Hotels">

- <RoomType productId="17147;1605909;11857" name="Classic" nights="5" startDate="2008-01-15T03:00:00-02:00" isAvailable="true" roomId="231" hotelRoomTypeId="1605909">

<Avail offset="0" status="true" />

<Avail offset="1" status="true" />

<Avail offset="2" status="true" />

<Avail offset="3" status="true" />

<Avail offset="4" status="true" />

- <Occup occupId="17147;1605909;11857;2;1;0" maxAdult="2" maxChild="0" price="845.55" tax="40.25" avrNightPrice="169.11">

<Board bbId="2" name="Café da Manhã Americano" price="0" default="false" />

<Room seqNum="1" adultNum="1" childNum="0" />

<Price offset="0" value="169.11" />

<Price offset="1" value="169.11" />

<Price offset="2" value="169.11" />

<Price offset="3" value="169.11" />

<Price offset="4" value="169.11" />

</Occup>

</RoomType>

- <RoomType productId="17147;1605910;11857" name="Standard" nights="5" startDate="2008-01-15T03:00:00-02:00" isAvailable="true" roomId="3" hotelRoomTypeId="1605910">

<Avail offset="0" status="true" />

<Avail offset="1" status="true" />

<Avail offset="2" status="true" />

<Avail offset="3" status="true" />

<Avail offset="4" status="true" />

- <Occup occupId="17147;1605910;11857;2;1;0" maxAdult="2" maxChild="0" price="950.55" tax="45.25" avrNightPrice="190.11">

<Board bbId="2" name="Café da Manhã Americano" price="0" default="true" />

<Room seqNum="1" adultNum="1" childNum="0" />

<Price offset="0" value="190.11" />

<Price offset="1" value="190.11" />

<Price offset="2" value="190.11" />

<Price offset="3" value="190.11" />

<Price offset="4" value="190.11" />

</Occup>

</RoomType>

</Hotel>

 

 

esse é o xml. Olhando o acima a grid só iria trazer e registros. Eu consegui montando uma grid manualmente...e já funcionaou e consegui ler todas as informações....

 

Mas se eu rodar um for e alguma lina no xml nao estiver esse começa com os error. pois nem todas as tegs principais tem um codigo para eu comparar como de cima para verificaer se esta na mesma arvore.

 

 

Alguem sabe alguma forma mais facil de ler arquivos xml ?????

 

Obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.