dbTalk Databases Forums  

Need help for reading XML file

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss Need help for reading XML file in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bofcilo
 
Posts: n/a

Default Need help for reading XML file - 11-24-2009 , 06:11 AM






This is content of xml file :

<?xml version="1.0" standalone="yes"?>
<dstSifarnici xmlns="http://tempuri.org/dstSifarnici.xsd">
<TipLecenja>
<Sifra>1</Sifra>
<Oznaka>A</Oznaka>
<Opis>Ambulantno</Opis>
</TipLecenja>
<TipLecenja>
<Sifra>2</Sifra>
<Oznaka>S</Oznaka>
<Opis>Stacionarno</Opis>
</TipLecenja>
</dstSifarnici>

I try with :
create variable x XML;
select xp_read_file('d:\xml\ef_vrsta.xml') into x;
select * from openxml(x,'//*') with (sifra int ':mp:Sifra');

OK last statement is something i need, but i don't know how to write
SELECT with openxml.
Result of select should be:

1,A,Ambulantno
2,S,Stacionarno

TIA

Reply With Quote
  #2  
Old   
Kory Hodgson (Sybase iAnywhere)
 
Posts: n/a

Default Re: Need help for reading XML file - 11-24-2009 , 12:33 PM






Hi,

I found that this works:

select * from
openxml('<dstSifarnici><TipLecenja><Sifra>1</Sifra><Oznaka>A</Oznaka><Opis>Ambulantno</Opis></TipLecenja><TipLecenja><Sifra>2</Sifra><Oznaka>S</Oznaka><Opis>Stacionarno</Opis></TipLecenja></dstSifarnici>','/dstSifarnici/TipLecenja')
WITH ( Sifra CHAR(2000) 'Sifra',
Oznaka CHAR(16) 'Oznaka',
Opis CHAR(32) 'Opis');

If you include: xmlns="http://tempuri.org/dstSifarnici.xsd" it doesn't
seem to work however.



Bofcilo wrote:
Quote:
This is content of xml file :

?xml version="1.0" standalone="yes"?
dstSifarnici xmlns="http://tempuri.org/dstSifarnici.xsd"
TipLecenja
Sifra>1</Sifra
Oznaka>A</Oznaka
Opis>Ambulantno</Opis
/TipLecenja
TipLecenja
Sifra>2</Sifra
Oznaka>S</Oznaka
Opis>Stacionarno</Opis
/TipLecenja
/dstSifarnici

I try with :
create variable x XML;
select xp_read_file('d:\xml\ef_vrsta.xml') into x;
select * from openxml(x,'//*') with (sifra int ':mp:Sifra');

OK last statement is something i need, but i don't know how to write
SELECT with openxml.
Result of select should be:

1,A,Ambulantno
2,S,Stacionarno

TIA

Reply With Quote
  #3  
Old   
Kory Hodgson (Sybase iAnywhere)
 
Posts: n/a

Default Re: Need help for reading XML file - 11-24-2009 , 12:38 PM



Quote:
If you include: xmlns="http://tempuri.org/dstSifarnici.xsd" it
doesn't seem to work however.
This is likely because I can't find the page even through a web browser.


Kory Hodgson (Sybase iAnywhere) wrote:
Quote:
Hi,

I found that this works:

select * from
openxml('<dstSifarnici><TipLecenja><Sifra>1</Sifra><Oznaka>A</Oznaka><Opis>Ambulantno</Opis></TipLecenja><TipLecenja><Sifra>2</Sifra><Oznaka>S</Oznaka><Opis>Stacionarno</Opis></TipLecenja></dstSifarnici>','/dstSifarnici/TipLecenja')

WITH ( Sifra CHAR(2000) 'Sifra',
Oznaka CHAR(16) 'Oznaka',
Opis CHAR(32) 'Opis');

If you include: xmlns="http://tempuri.org/dstSifarnici.xsd" it doesn't
seem to work however.



Bofcilo wrote:
This is content of xml file :

?xml version="1.0" standalone="yes"?
dstSifarnici xmlns="http://tempuri.org/dstSifarnici.xsd"
TipLecenja
Sifra>1</Sifra
Oznaka>A</Oznaka
Opis>Ambulantno</Opis
/TipLecenja
TipLecenja
Sifra>2</Sifra
Oznaka>S</Oznaka
Opis>Stacionarno</Opis
/TipLecenja
/dstSifarnici

I try with :
create variable x XML;
select xp_read_file('d:\xml\ef_vrsta.xml') into x;
select * from openxml(x,'//*') with (sifra int ':mp:Sifra');

OK last statement is something i need, but i don't know how to write
SELECT with openxml.
Result of select should be:

1,A,Ambulantno
2,S,Stacionarno

TIA

Reply With Quote
  #4  
Old   
Bofcilo
 
Posts: n/a

Default Re: Need help for reading XML file - 11-24-2009 , 01:04 PM



On Nov 24, 7:38*pm, "Kory Hodgson (Sybase iAnywhere)"
<khodgson (AT) A_SPAM_FREE_sybase (DOT) com> wrote:
Quote:
*> If you include: *xmlns="http://tempuri.org/dstSifarnici.xsd" it
*> doesn't seem to work however.

This is likely because I can't find the page even through a web browser.

Kory Hodgson (Sybase iAnywhere) wrote:

Hi,

I found that this works:

select * from
openxml('<dstSifarnici><TipLecenja><Sifra>1</Sifra><Oznaka>A</Oznaka><Opis>Ambulantno</Opis></TipLecenja><TipLecenja><Sifra>2</Sifra><Oznaka>S</Oznaka><Opis>Stacionarno</Opis></TipLecenja></dstSifarnici>','/dstSifarnici/TipLecenja')

WITH ( Sifra * *CHAR(2000) * *'Sifra',
* * * *Oznaka * CHAR(16) * *'Oznaka',
* * * *Opis * * CHAR(32) * *'Opis');

If you include: *xmlns="http://tempuri.org/dstSifarnici.xsd" it doesn't
seem to work however.

Bofcilo wrote:
This is content of xml file :

?xml version="1.0" standalone="yes"?
dstSifarnici xmlns="http://tempuri.org/dstSifarnici.xsd"
* <TipLecenja
* * <Sifra>1</Sifra
* * <Oznaka>A</Oznaka
* * <Opis>Ambulantno</Opis
* </TipLecenja
* <TipLecenja
* * <Sifra>2</Sifra
* * <Oznaka>S</Oznaka
* * <Opis>Stacionarno</Opis
* </TipLecenja
/dstSifarnici

I try with :
create variable x XML;
select xp_read_file('d:\xml\ef_vrsta.xml') into x;
select * from openxml(x,'//*') with (sifra int ':mp:Sifra');

OK last statement is something i need, but i don't know how to write
SELECT with openxml.
Result of select should be:

1,A,Ambulantno
2,S,Stacionarno

TIA
Thanks, it's work. By the way, I did try some version of code from
User guide. In the meantime I crash on something because I hate
Microsoft. The part <<xmlns="http://tempuri.org/dstSifarnici.xsd">>
was deleted from my XML, and iSQL still return error ... Notepad add
"BOM" on the beginning of XML . Hidden.

So, another question... How to setup code page of XML ?? Importing
data from XML works, but with wrong code page.

Reply With Quote
  #5  
Old   
Kory Hodgson (Sybase iAnywhere)
 
Posts: n/a

Default Re: Need help for reading XML file - 11-24-2009 , 01:32 PM



I'm not too familiar with XML code pages. I would post that as a new
thread, it is likely to get more visibility that way.

Bofcilo wrote:
Quote:
On Nov 24, 7:38 pm, "Kory Hodgson (Sybase iAnywhere)"
khodgson (AT) A_SPAM_FREE_sybase (DOT) com> wrote:
If you include: xmlns="http://tempuri.org/dstSifarnici.xsd" it
doesn't seem to work however.

This is likely because I can't find the page even through a web browser.

Kory Hodgson (Sybase iAnywhere) wrote:

Hi,
I found that this works:
select * from
openxml('<dstSifarnici><TipLecenja><Sifra>1</Sifra><Oznaka>A</Oznaka><Opis>Ambulantno</Opis></TipLecenja><TipLecenja><Sifra>2</Sifra><Oznaka>S</Oznaka><Opis>Stacionarno</Opis></TipLecenja></dstSifarnici>','/dstSifarnici/TipLecenja')
WITH ( Sifra CHAR(2000) 'Sifra',
Oznaka CHAR(16) 'Oznaka',
Opis CHAR(32) 'Opis');
If you include: xmlns="http://tempuri.org/dstSifarnici.xsd" it doesn't
seem to work however.
Bofcilo wrote:
This is content of xml file :
?xml version="1.0" standalone="yes"?
dstSifarnici xmlns="http://tempuri.org/dstSifarnici.xsd"
TipLecenja
Sifra>1</Sifra
Oznaka>A</Oznaka
Opis>Ambulantno</Opis
/TipLecenja
TipLecenja
Sifra>2</Sifra
Oznaka>S</Oznaka
Opis>Stacionarno</Opis
/TipLecenja
/dstSifarnici
I try with :
create variable x XML;
select xp_read_file('d:\xml\ef_vrsta.xml') into x;
select * from openxml(x,'//*') with (sifra int ':mp:Sifra');
OK last statement is something i need, but i don't know how to write
SELECT with openxml.
Result of select should be:
1,A,Ambulantno
2,S,Stacionarno
TIA

Thanks, it's work. By the way, I did try some version of code from
User guide. In the meantime I crash on something because I hate
Microsoft. The part <<xmlns="http://tempuri.org/dstSifarnici.xsd"
was deleted from my XML, and iSQL still return error ... Notepad add
"BOM" on the beginning of XML . Hidden.

So, another question... How to setup code page of XML ?? Importing
data from XML works, but with wrong code page.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.