Search  
Saturday, February 11, 2012 ..:: Forum ::.. Register  Login
 Forum Minimize
Pentru a putea posta mesaje trebuie să vă înregistraţi.
Notă: Mesajele cu conţinut jignitor sau ilegal (inclusiv cereri de soft piratat) nu sunt acceptate şi vor fi şterse imediat .

Pentru a primi raspunsuri rapide si corecte, scrieti in mesaj ce intentionati sa faceti, ce mesaj de eroare primiti, in ce context si in urma caror actiuni. De asemenea, mentionati versiunea de FoxPro in care lucrati!
Dacă nu specificați versiunea, se consideră VFP 9.0 SP2.

SearchForum Home
  Visual FoxPro  .NET Interop  XMLToCursor...
 XMLToCursor
 
 8/23/2010 12:16:00 PM
User is offlineRomeo
495 posts
2nd


XMLToCursor
 (N/A)

<?xml version="1.0"?>
<!-- Chapter8\Catalog1.xml -->
<Catalog>
    <Product>
              <ProductID>F10</ProductID>
              <ProductName>Shimano Calcutta </ProductName>
              <ListPrice>47.76</ListPrice>
    </Product>
    <Product>
              <ProductID>F20</ProductID>
              <ProductName>Bantam Lexica</ProductName>
              <ListPrice>49.99</ListPrice>
    </Product>
</Catalog>

Am fisierul de mai sus (luat dintr-o carte de C#) salvat in C:\crstoxml.xml (indentarea in fisier este facuta cu tab-uri). Apoi am incercat sa-l transform in cursor folosind instructiune XMLTOCURSOR() cu diversi parametri: XMLTOCURSOR("e:\xmltocrs.xml", "crs",0) - vfp9.

Am obtinut invariabil mesaje de eroare de forma: XML Parse error: Invalid at the top level of the document line 1, Position1. e:\xmltocrs.xml

Cum pot transforma un asemenea xml, produs de C#, in xml pe care vfp9 sa-l poata prelucra fara probleme ?


test
 8/23/2010 12:32:27 PM
User is offlineDaniel Buduru
2141 posts
1st




Re: XMLToCursor
 (N/A)
Nu ai pus flagul corect. Asa cum ai scris comanda, primul parametru trebuie sa fie un string xml, in timp ce acolo e numele fisierului.
Incearca asta:

XMLTOCURSOR("e:\xmltocrs.xml", "crs", 512)

Daniel Buduru
 8/23/2010 12:33:06 PM
User is offlineRomeo
495 posts
2nd


Am rezolvat
 (N/A)

XMLTOCURSOR("e:\xmltocrs.xml", "crs",512)

Am gasit exemple la adresa: http://msdn.microsoft.com/en-us/library/cbbwtcbh(VS.80).aspx 


test
 8/23/2010 2:23:46 PM
User is offlineRomeo
495 posts
2nd


Re: Am rezolvat
 (N/A)

<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<Catalog>
 <Product Type="Spinning Reel" SupplierId="5">
  <ProductID>F10</ProductID>
  <ProductName>Shimano Calcutta </ProductName>
  <ListPrice>47.76</ListPrice>
 </Product>
 <Product Type="Baitcasting Reel" SupplierId="3">
  <ProductID>F20</ProductID>
  <ProductName>Bantam Lexica</ProductName>
  <ListPrice>49.99</ListPrice>
 </Product>
</Catalog>

La xml-ul anterior am adaugat codul cu rusu elermentelor Product. Dupa ce am facut coversia, noile atribule introduse (Type si SupplierId). Am aplicat xmltocursor, dar aceste atribute nu s-au regasit in campurile cursorului. Poate foxul sa le preaia in cursor ? - desigur le puteam adauga ca elemente ialaturi de <ProductId>,<ProductName>.... dar ma intereseaza in aceasta forma daca pot fi preluate.


test
 8/23/2010 2:50:37 PM
User is offlineDaniel Buduru
2141 posts
1st




Re: Am rezolvat
 (N/A) Modified By Daniel Buduru  on 8/23/2010 2:22:42 PM)
Intreabarea ar suna cam asa:
"Poate foxul sa decida singur ce atribute sa devina campuri fara a i se preciza schema?"
Raspunsul este NU.
Exista o nota chiar pe pagina referita in postul precedent:

The XML must generally conform to a format that can be interpreted as a table in addition to being well-formed. Well-formed XML that is not easily deconstructed into a table format will fail to import.

Poate cu indicand  o schema corespunzatoare (xsd) se poate importa, dar mixarea atributelor si elementelor in acelasi xml nu e de natura sa faciliteze operatia.

Un xml attribute-centric poate fi importat la fel de bine ca si unul element-centric:

<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
<Catalog>
 <Product Type="Spinning Reel" SupplierId="5" ID="F10" Name="Shimano Calcutta" ListPrice="47.76">
 </Product>
 <Product Type="Baitcasting Reel" SupplierId="3" ID="F20" Name="Bantam Lexica" ListPrice="49.99">
 </Product>
</Catalog>

Dar mixajul atribut-element nu poate fi preluat fara schema xsd.

Daniel Buduru
  Visual FoxPro  .NET Interop  XMLToCursor...

Search  Forum Home         

 Google Ads Minimize

    

Copyright 2002-2010 Profox   Terms Of Use  Privacy Statement