Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question on processing XML file
Message
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
00854652
Message ID:
00893869
Views:
20
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform