Pasar xml a cursor

Me gustaría saber si me puedes ayudar, tengo un archivo xlm que requiero leer desde visual foxpro 9, estuve mirando en internet y encontré esta función: xmltocursor. El problema es que cuando la ejecuto me marca el siguiente error: XML Parse error: Declaración xml no válida. Line 3, position 3 <?xml version="1.0" encoding="UTF-8"?>.
Yo estoy escribiendo lo siguiente: XMLTOCURSOR("oc_xml.xml","MiCursor", 512)
Y he estado mirando en internet pero no he encontrado solución.
El archivo es así:
<?xml version="1.0" encoding="UTF-8" ?>
- <eanucc:envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:eanucc="http://www.uc-council.org/smp/schemas/eanucc" xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg" xsi:schemaLocation="http://www.uc-council.org/smp/schemas/eanucc As2Envelope.xsd http://www.uc-council.org/smp/schemas/eanucc Transaction.xsd http://www.uc-council.org/smp/schemas/eanucc DocumentCommand.xsd http://www.uc-council.org/smp/schemas/eanucc Order.xsd http://www.uc-council.org/smp/schemas/fmcg FmcgIdentification.xsd" communicationVersion="1.0">
- <messageHeader creationDate="2010-02-02T00:00:00">
  <userId>CEN</userId>
<password>PEDIDOS</password>
  <messageIdentifier>142-131</messageIdentifier>
- <to>
  <gln>7709999008174</gln>
  </to>
- <from>
  <gln>7707185370005</gln>
  </from>
- <representingParty>
  <gln>NORMANETCEN01</gln>
  </representingParty>
  </messageHeader>
-
<body>
- <eanucc:transaction>
- <entityIdentification>
  <uniqueCreatorIdentification>142-131</uniqueCreatorIdentification>
- <contentOwner>
  <gln>7707185370005</gln>
  </contentOwner>
  </entityIdentification>
- <command>
- <eanucc:documentCommand>
- <documentCommandHeader type="ADD">
- <entityIdentification>
  <uniqueCreatorIdentification>142-131</uniqueCreatorIdentification>
- <contentOwner>
  <gln>7707185370005</gln>
  </contentOwner>
  </entityIdentification>
  </documentCommandHeader>
- <documentCommandOperand>
- <eanucc:order documentStatus="ORIGINAL" creationDate="2010-02-02T00:00:00">
-
<paymentTerms type="DISCOUNT" eventType="DATE_INVOICE_RECEIVED">
- <netPayment>
  <timePeriodDue type="DAYS">30</timePeriodDue>
  </netPayment>
  </paymentTerms>
  <movementDate>2010-02-02</movementDate>
  <movementDateType>REQUESTED_PICKUP</movementDateType>
- <typedEntityIdentification entityType="ORDER">
- <entityIdentification>
  <uniqueCreatorIdentification>142-131</uniqueCreatorIdentification>
- <contentOwner>
  <gln>7707185370005</gln>
  </contentOwner>
  </entityIdentification>
  </typedEntityIdentification>
- <buyer>
  <gln>7707185370005</gln>
  </buyer>
- <seller>
  <gln>7709999008174</gln>
  </seller>
- <shipParty identificationType="SHIP_TO">
  <gln>7707185371422</gln>
  </shipParty>
-
<lineItem number="1">
- <netPrice>
  <amount currencyISOcode="">16,679.00</amount>
  </netPrice>
  <requestedQuantity>2</requestedQuantity>
- <itemIdentification>
  <gtin>7702057071813</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="2">
- <netPrice>
  <amount currencyISOcode="">6,006.00</amount>
  </netPrice>
  <requestedQuantity>2</requestedQuantity>
- <itemIdentification>
  <gtin>7702057124021</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="3">
- <netPrice>
  <amount currencyISOcode="">26,391.00</amount>
  </netPrice>
  <requestedQuantity>2</requestedQuantity>
- <itemIdentification>
  <gtin>7707172687802</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="4">
- <netPrice>
  <amount currencyISOcode="">15,620.00</amount>
  </netPrice>
  <requestedQuantity>2</requestedQuantity>
- <itemIdentification>
  <gtin>7702132007041</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="5">
- <netPrice>
  <amount currencyISOcode="">5,597.00</amount>
  </netPrice>
  <requestedQuantity>3</requestedQuantity>
- <itemIdentification>
  <gtin>77014535</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="6">
- <netPrice>
  <amount currencyISOcode="">5,224.00</amount>
  </netPrice>
  <requestedQuantity>4</requestedQuantity>
- <itemIdentification>
  <gtin>7702057168049</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="7">
- <netPrice>
  <amount currencyISOcode="">3,765.00</amount>
  </netPrice>
  <requestedQuantity>4</requestedQuantity>
- <itemIdentification>
  <gtin>7703381002382</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="8">
- <netPrice>
  <amount currencyISOcode="">11,874.00</amount>
  </netPrice>
  <requestedQuantity>4</requestedQuantity>
- <itemIdentification>
  <gtin>7702870999745</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="9">
- <netPrice>
  <amount currencyISOcode="">3,688.00</amount>
  </netPrice>
  <requestedQuantity>4</requestedQuantity>
- <itemIdentification>
  <gtin>7702123832645</gtin>
  </itemIdentification>
  </lineItem>
-
<lineItem number="10">
- <netPrice>
  <Amount...

1 respuesta

Respuesta
1
No nada que ver asi no se hace, o almenos nunk lo e intentado asi...
Esto en cualquier combo!
lcXLBook = GETFILE("xls")
IF !FILE( lcXLBook )
oVoz = CreateObject("SAPI.SpVoice")
oVoz.Speak('Any file was find. Try again please')
RETURN .F.
ELSE
thisform.text1.value=LOWER(ALLTRIM(lcXLBooK))
thisform.command3.Enabled= .T.
ENDIF
IMPORT FROM ALLTRIM(thisform.text1.Value) TYPE XL5
SELECT * FROM (xDataTemp) INTO CURSOR xInformacion
y ahi ya lo tenes en un cursor lo demas ahi lo haces o me preguntas que queres!
Hola!!
Muchas gracias por tu respuesta.
Estuve mirando el código que me enviaste para importar, pero ese código importa xls a dbf y yo necesito es importar un xml lo cual no es lo mismo.
Estuve revisando en la ayuda, el comando import, pero dentro de los tipos de archivo que importa no se encuentra el xml.
Sin  embargo muchas gracias porque siempre había importado xls pero usando el asistente de visual fox, nunca por programación, entonces es algo nuevo que aprendí.
De todos modos si sabes cómo importar xml te lo agradezco...
Jajajajajaja ok! Investigare y si te puedo ayudar no te preocupes que te ayudare!
ok, muchas gracias
LOCAL xdoc AS MSXML2. DOMDocument
Clear
*!* Creamos un objeto basado en MSXML
xdoc=CREATEOBJECT('MSXML2.DOMdocument')
*!* Cargamos el archivo XML a procesar
xdoc.LOAD('CDs.xml')
*!* Llamamos a la función LeerCDs pasándole el nodo raíz (DCs)
LeerCDs(xdoc.documentElement.childNodes)
FUNCTION LeerCDs
LPARAMETERS root AS MSXML2.IXMLDOMNode
LOCAL CHILD AS MSXML2.IXMLDOMNode
*!* Aqui se procesan los nodos (DC,Artista,Titulo,Temas y Tema)
FOR EACH CHILD IN root
    IF CHILD.nodeName="CD"
       *!* Mostramos la información referente al CD
       ? REPLICATE("=",30)
       *!* CHILD.ATTRIBUTES.ITEM(0).TEXT hace referencia al primer atributo del nodo
       ? "Género : "+CHILD.ATTRIBUTES.ITEM(0).TEXT
    ELSE
       IF CHILD.nodeName="Artista"
          *!* Mostramos la información referente al artista
          ? "Tipo de Artista : "+CHILD.ATTRIBUTES.ITEM(0).TEXT
          ? "Artista : "+CHILD.TEXT
       ELSE
          IF CHILD.nodeName="Titulo"
             *!* Mostramos la información referente al título
             ? "Título del DC : "+CHILD.TEXT
             ? REPLICATE("=",30)
          ELSE
             IF CHILD.nodeName="Temas"
               *!* Mostramos el número de temas
               ? "Número de temas del CD : "+CHILD.ATTRIBUTES.ITEM(0).TEXT
             ELSE
               IF CHILD.nodeName="Tema"
                  *!* Mostramos los temas con su duración
                   ? CHILD.TEXT+" "+CHILD.ATTRIBUTES.ITEM(0).TEXT
               ENDIF
             ENDIF
          ENDIF
       ENDIF
    ENDIF
    *!* Si el nodo que estamos procesando tiene descendencia volvemos a llamar a la función LeerCDs pasandole el nodo actual
    *!* Esto sucede cuando se procesa el nodo (Temas)
    IF CHILD.hasChildNodes
       LeerCDs(CHILD. ChildNodes)
    ENDIF
Endfor
Endfunc
Esto encontre no se si te sirva

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas