Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to convert this to cursors
Message
De
14/06/2018 13:52:52
 
 
À
14/06/2018 10:15:07
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Divers
Thread ID:
01660726
Message ID:
01660730
Vues:
110
J'aime (1)
>Hi All,
>
>There are two cursors at this XML string. Header and lines. I couldn't convert neither xmltocursor or xmladapter.
>
>Any help?

Metin

The products level poses no problem, it can be fetched directly through XMLTOCURSOR().

To read the order information level, you can transform the document and replicate the order element with its attributes, but in the process clearing its children (the "product" elements). When XMLTOCURSOR() reads the resulting document, it won't use the "product" element as the source axis to infer the schema.
LOCAL XMLSource AS String

TEXT TO m.XMLSource NOSHOW
<order Id="458362379" 
MessageId="1701653104" 
RestaurantName="Serez Dondurmacisi, Kartal (Kordonboyu Mah.)" 
RestaurantCatalog="postakip" 
RestaurantCategory="8cb94060-7642-44e4-b18c-720a44349424" 
CustomerName="metin emre" 
CustomerId="5039891" 
CustomerType="3"
PaymentNote="Nakit (nakit ödeme) - Lütfen fis getiriniz." 
OrderTotal="14.00" 
CustomerPhone="3213213212" 
CustomerPhone2="" 
PromoCode="" 
City="postakip" 
Region="deneme semti" 
Organization="" 
Address="zcxvcxzvcxzvcxzvxc" 
AddressDescription="fgdsgfdsgfdsg" 
AddressId="8670d8154e1084e85a590a7e3b7bd6c0" 
PaymentMethodId="1" 
DeliveryTime="2018.06.14 12:55" 
ChangeInTotal="0.00" 
Currency="YSM" OrderNote="">
<product id="3a8647be80e005fad8396ecb3d91a033" 
Name="Keçi Sütlü Maras Dondurmasi (Top)" 
Price="6.00" 
ListPrice="6.00" 
Quantity="1" 
Options="" 
OptionIds="" 
OrderIndex="1" 
ParentIndex="0" 
PromoParentIndex="0" 
ProductOptionId="" />
<product id="d25c6827d792020856e60ceb6aa6e66d" 
Name="Bodrum Mandalinali Dondurma (Top)" 
Price="4.00" 
ListPrice="4.00" 
Quantity="1" 
Options="" 
OptionIds="" 
OrderIndex="2" 
ParentIndex="0" 
PromoParentIndex="0" 
ProductOptionId="" />
<product id="0c23a1fa5b8ee1f73a95dbdf6546e3c0" 
Name="Karadutlu Dondurma (Top)" 
Price="4.00" 
ListPrice="4.00" 
Quantity="1" 
Options="" 
OptionIds="" 
OrderIndex="3" 
ParentIndex="0" 
PromoParentIndex="0" 
ProductOptionId="" />
</order>
ENDTEXT

LOCAL XMLAttributesToColumns AS String

TEXT TO m.XMLAttributesToColumns NOSHOW
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  
  <xsl:output method="xml"/>

  <xsl:template match="/">
    <xsl:element name="VFPData">
      <xsl:for-each select="*">
	      <xsl:element name="{name()}">
	        <xsl:for-each select="@*">
	          <xsl:attribute name="{name()}">
	            <xsl:value-of select="."/>
	          </xsl:attribute>
	        </xsl:for-each>
	      </xsl:element>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
ENDTEXT

LOCAL XMLDOM AS MSXML2.DOMDocument60
LOCAL XSLT AS MSXML2.DOMDocument60

m.XMLDOM = CREATEOBJECT("MSXML2.DOMDocument.6.0")
m.XMLDOM.async = .F.
m.XMLDOM.loadXML(m.XMLSource)

m.XSLT = CREATEOBJECT("MSXML2.DOMDocument.6.0")
m.XSLT.async = .F.
m.XSLT.loadXML(m.XMLAttributesToColumns)

XMLTOCURSOR(m.XMLDOM.transformNode(m.XSLT), "curOrders")
BROWSE

XMLTOCURSOR(m.XMLSource, "curProducts")
BROWSE
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform