Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java File Parser

  • 13-07-2005 12:34PM
    #1
    Registered Users, Registered Users 2 Posts: 995 ✭✭✭


    I need to write a single Java class to parse the following type of string input that will be loaded from a file.
    The goal is to extract the XML and store each XML doc in a String array.

    (After that each string in the string array is stored as a BLOB to be eventually loaded into an Oracle staging area after transformation.)

    Below is the type of input string. I want to ditch all entries beginning with '@' and have each XML doc as a discrete string that I will add to a string array.

    Any ideas? Im working on this myself but I'm pretty certain that there are better programmers who would have ideas of a better solution.

    @DOC
    @APPID abgtest
    @APPHNDL 108
    @DOCSTD OAGIS
    @DOCTYP AddPurchaseOrder
    @DOCREV 001
    @MFGPROSITE abgtest
    @ACKLVLREQD 0
    @ORIGDOCID 00000032
    @DOCLNG ge
    @CODEPG iso8859-1
    @SRCCOMP
    @SRCPROC xqsopopb.p
    @SRCUSERID iri
    @DATA
    <?xml version="1.0"?> <AddPurchaseOrder> <ApplicationArea> <Sender> <LogicalId>3333-3333</LogicalId> <Component>INTO58</Component> <Task>98-572-4553</Task> <ReferenceId>32</ReferenceId> </Sender> <BODId>32</BODId> </ApplicationArea> <DataArea> <PurchaseOrder> <Header> <DocumentIds> <DocumentId> <Id>50153942</Id> </DocumentId> <CustomerDocumentId> <Id>110332</Id> </CustomerDocumentId> </DocumentIds> <DocumentReferences> <PurchaseOrderDocumentReference> <Note></Note> </PurchaseOrderDocumentReference> </DocumentReferences> <ShipNote></ShipNote> <Priority></Priority> <TransportationTerm> <FreightTerms></FreightTerms> </TransportationTerm> <Parties> <BillToParty> <Addresses> <Address> <AddressLine> </AddressLine> </Address> </Addresses> </BillToParty> <ShipToParty> <Addresses> <Address> <AddressLine>Firma 02</AddressLine> <AddressLine>Kuhbrueckenstr. 18</AddressLine> <AddressLine>Postfach 10 13 03</AddressLine> <City>Hameln</City> <PostalCode>31785</PostalCode> <Region></Region> <AddressID></AddressID> <StateOrProvince>D</StateOrProvince> <County>Niedersachsen</County> <Country>GER</Country> </Address> </Addresses> </ShipToParty> <CarrierParty> <Name></Name> <Addresses> <DropShipAddress> <AddressLine></AddressLine> </DropShipAddress> </Addresses> </CarrierParty> </Parties> <UserArea> <Header_UserArea> <ModeOfShipment></ModeOfShipment> </Header_UserArea> </UserArea> </Header> <Line> <LineNumber>1</LineNumber> <OrderItem> <ItemIds> <ItemId> <Id>04S</Id> </ItemId> </ItemIds> <ProductLine>00319368</ProductLine> </OrderItem> <OrderQuantity>1</OrderQuantity> <NeedDeliveryDate> 2005-07-27 </NeedDeliveryDate> <ShipNote></ShipNote> <Priority></Priority> <Parties> <CarrierParty> <Addresses> <DropShipAddress> <AddressLine></AddressLine> </DropShipAddress> </Addresses> </CarrierParty> </Parties> <DocumentReferences> <PurchaseOrderDocumentReference> <Note></Note> </PurchaseOrderDocumentReference> </DocumentReferences> <UserArea> <Line_UserArea> <PartialShipmentAllowed></PartialShipmentAllowed> </Line_UserArea> </UserArea> </Line> </PurchaseOrder> </DataArea> </AddPurchaseOrder>
    @DOCEND

    @DOC

    <?xml version="1.0"?> <AddPurchaseOrder> ......
    </AddPurchaseOrder>

    @DOCEND


Advertisement