Xml diffrent structure in One Xml File

JedrzejTJedrzejT Member Posts: 267
Hello,

I have problem with import xml via XmlPort (Nav 5, SQL)
As i know XmlPort must have strongly defined structure.
I have 2 elements with diffrent data inside (based on data inside it)

So I have Element 'Meta' with structure like that
Meta	Element
  DeviceType	Element
  Encoding	Element	
  RxDT	Element	
  NetworkId	Element	
  TxDT	Element	
  MsgType	Element	

And the same element with other strucutre
Meta	Element
  DeviceType	Element
  Encoding	Element	
  TxDT	Element	
  NetworkId	Element	
  MsgType	Element	

Problem is that one structure have TxDt and next NetworkId, and other structure is NetworkId,TxDt. Both strucutres exist in the same Xml Stream (can't be imported via 2 diffrent xmlports)

Maybe someone have an idea how to handle that without building new import without xmlport?

Comments

  • KisuKisu Member Posts: 381
    So do you say your xml file looks something like this?:
    <?xml version="1.0" encoding="utf-8"?>
    <root>
      <Meta>
        <DeviceType/>
        <Encoding/>   
        <RxDT/>   
        <NetworkId/>   
        <TxDT/>  
        <MsgType/>   
      </Meta>
      <Meta>
        <DeviceType/>  
        <Encoding/>     
        <TxDT/>     
        <NetworkId/>     
        <MsgType/>
      </Meta>
    </root>
    
    

    For me it'd look wrongly formed xml file. Although the tags might be able to swap around with XMLDom automation before importing it. Then you'd be able to use same Meta element with childs on the xml file.

    Can you post the DTD of that xml file you are trying to import?
    K.S.
  • JedrzejTJedrzejT Member Posts: 267
    Hello,

    Thank You for answering on so old post.
    I can't attach DTD , becuse.. simple there are no DTD section inthis file.
    There is just first element on the begining

    For detail it look like that..
    <Subscription user="xxx" datetime="xxx">
      <Summary>
        <SomeFileds>xxx</SomeFileds>
        <SomeFileds>xxx</SomeFileds>
        <SomeFileds>xxx</SomeFileds>    
      </Summary>
      <Messages>
         <Msg PacketId="xxx" PosId="xxx">
            <SomeFileds>xxx</SomeFileds>
            <SomeFileds>xxx</SomeFileds>
            <SomeFileds>xxx</SomeFileds>
            <Data>
                <Msg>
                     </Meta>
                         <SomeFileds>xxx</SomeFileds>
                         [b]This meta element can have diffrent structure in one xml[/b]
                     </Meta>
                     <Data>
                         <SomeFileds>xxx</SomeFileds>
                         <SomeElements>
                            <SomeFileds>xxx</SomeFileds>
                         </SomeElements>
                     </Data>
    
                </Msg>          
            </Data>
         </Msg>
      </Messages>
    

    For now, because i don't have to use those "problematic fields" i just read file, replace wrong elements with other names and import like that. I just ask to know is there some other (better) way to do it (with XmlPort object)
Sign In or Register to comment.