Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newbie question on processing XML file
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Divers
Thread ID:
00854652
Message ID:
00893869
Vues:
21
Sergey

I am trying to use your suggested method using XMLTOCURSOR on sections of a hierarchical XML file:

The XML is as follows:
<?xml version = "1.0"?>
<Message>
        <MessageHeader>
                <SenderID>ABCCOY</SenderID>
                <RecipientID>MAINFREIGHT</RecipientID>
                <Configured>2001-10-01T09:10:00</Configured>
                <MessageID>1234567</MessageID>
                <MessageType>MANIFEST</MessageType>
                <MessageVersion>01</MessageVersion>
        </MessageHeader>
        <MessageBody>
                <ManifestHeader>
                        <Party Role="PICKUP">
                                <Code> ABC12</Code>
                                <Name>ABC COMPANY</Name>
                                <Address1>123 MAIN ST</Address1>
                                <Address2/>
                                <Suburb>PENROSE</Suburb>
                                <City>AUCKLAND</City>
                                <State/>
                                <PostCode/>
                                <Phone/>
                        </Party>
                </ManifestHeader>
                <Consignments>
                        <Consignment>
                                <ConsignmentNo>A1234567</ConsignmentNo>
                                <ConsignmentDate>2001-10-01</ConsignmentDate>
                                <MovementType/>
                                <Party Role="CHARGE">
                                        <Code>ABC12</Code>
                                        <Name/>
                                        <Address1/>
                                        <Address2/>
                                        <Suburb/>
                                        <City/>
                                        <State/>
                                        <PostCode/>
                                        <Phone/>
                                </Party>
                                <Party Role="SENDER">
                                        <Code> ABC12</Code>
                                        <Name>ABC COMPANY</Name>
                                        <Address1>123 MAIN ST</Address1>
                                        <Address2/>
                                        <Suburb>PENROSE</Suburb>
                                        <City>AUCKLAND</City>
                                        <State/>
                                        <PostCode/>
                                        <Phone/>
                                </Party>
                                <Party Role="RECEIVER">
                                        <Code/>
                                        <Name>DEF COMPANY</Name>
                                        <Address1>456 OTHER ST</Address1>
                                        <Address2/>
                                        <Suburb>SOCKBURN</Suburb>
                                        <City>CHRISTCHURCH</City>
                                        <State/>
                                        <PostCode/>
                                        <Phone/>
                                </Party>
                                <Reference Role="SENDER">PO12347</Reference>
                                <Line>
                                        <Items>21</Items>
                                        <PackageType>CTNS</PackageType>
                                        <Description>WIDGETS</Description>
                                        <Measurement Property="CUBIC">
                                                <Value>1.23</Value>
                                                <Unit>M3</Unit>
                                        </Measurement>
                                        <Measurement Property="WEIGHT">
                                                <Value>123</Value>
                                                <Unit>KG</Unit>
                                        </Measurement>
                                        <DangerousGoods>
                                                <DGClass/>
                                                <UNNumber/>
                                        </DangerousGoods>
                    <Dimensions>
                    <Quantity/>
                    <Length/>
                    <Width/>
                    <Height/>
                    </Dimensions>
                                </Line>
                                <Hire>
                                        <HireCompany>C</HireCompany>
                                        <HireType>R</HireType>
                                        <HireAccount>AB12345</HireAccount>
                                        <EquipmentType>P</EquipmentType>
                                        <Quantity>2</Quantity>
                                </Hire>
                                <Booking>
                                        <Required>Y</Required>
                                        <BookInFrom/>
                                        <BookInTo/>
                                        <Comment/>
                                </Booking>
                                <Total Units="ITEMS">21</Total>
                                <Total Units="CUBIC">1.23</Total>
                                <Total Units="WEIGHT">123</Total>
                                </Consignment>
                </Consignments>
                <ControlTotal>
                        <Total Units="CONSIGNMENTS">1</Total>
                </ControlTotal>
        </MessageBody>
</Message>
The file name is "manifest.xml", so I tried the following to "break out" the MessageHeader component:
lcXML = FILETOSTR("manifest.xml")
= XMLTOCURSOR( ;
                "<MessageHeader>" + ;
                STREXTRACT(lcXml, "<MessageHeader>", "</MessageHeader>") + "</MessageHeader>", ;
                "crsMessageHeader")
However when I did this I got an error:

"Unable to infer XML schema"

Can you advise me on how to make use of XMLTOCURSOR in this context?

Thanks
Chris Palmer
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform