About EasyMorph Tutorials & Examples Web-help

Parse XML in EasyMorph

Hi,

In EasyMorph there’s an action to read in XML or to parse an XML.
One problem that we encounter is when we have a large XML with a lot of nested elements.
When we select multiple specific nodes from the XML, we get multiple rows in our table making it hard to process further. Also, the parent elements are not repeated in the child rows making it even more difficult.
Could you post a simple example with some nested elements some levels deep with an illustration how we can get all the data and put it in a nice plain table for export to a database.

Could the action be altered so that when the XML is parsed, the information is automatically set in a nice table that requires no further transformations ?

Thanks !
Nikolaas

@dgudkov : I found some other examples on the forum. I managed to get the required output when parsing the XML using the shift up/down action combined with fill down. Does it seem to you a good way of getting all the info of nested elements on 1 record ?

We’re aware of the problem of having a more convenient way of flattening results of XML and JSON import/parsing and will do something to address it pretty soon.

2 Likes

Hi,we also have the problem all the time because XML is so flexible and dynamic. The best thing would be to have an XSD parser that determines the restrictions (data types, lengths…) as well as the loops (minOccurs, maxOccurs …) from an XSD file.

The information from the XSD-File (if there is one) should be used, to parse the corresponding XML.

like this …

<xs:complexType name="markierung">
	<xs:sequence>
		<xs:element name="farbmarkierung" minOccurs="1" maxOccurs="1">
			<xs:complexType>
				<xs:sequence>
					<xs:element name="markierungsart" type="char2" nillable="true" /> <!-- AAW: neues Feld: wo und wie soll markiert werden; abgeleitet u.a. von SMSTABEN -->
					<xs:element name="markierungsarttext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="beideseiten" type="char1" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="farbart" type="char2" nillable="true" /> <!-- AAW: neues Feld, aber abgeleitet u.a. von SMWFARBE -->
					<xs:element name="farbarttext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="muster" type="char2" nillable="true" /> <!-- AAW: neues Feld, aber abgeleitet u.a. von SM1STRI, SM2STRI, SM1KREUZ -->
					<xs:element name="mustertext" type="char80" nillable="true"/> <!-- AAW: neues Feld -->
					<xs:element name="hintergrundfarbe" type="char2" nillable="true" /> <!-- AAW: neues Feld, aber abgeleitet u.a. von SMFARBE1/2 -->
					<xs:element name="hintergrundfarbetext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="erstefarbemuster" type="char2" nillable="true" /> <!-- AAW: neues Feld, aber abgeleitet u.a. von SMFARBE1/2 -->
					<xs:element name="erstefarbemustertext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="zweitefarbemuster" type="char2" nillable="true" /> <!-- AAW: neues Feld, aber abgeleitet u.a. von SMFARBE1/2 -->
					<xs:element name="zweitefarbemustertext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="drittefarbemuster" type="char2" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="drittefarbemustertext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
				</xs:sequence>
			</xs:complexType>
		</xs:element>
		<xs:element name="chargentrennung" minOccurs="1"
			maxOccurs="1">
			<xs:complexType>
				<xs:sequence>
					<xs:element name="mitwasserfarbe" type="janein" nillable="true" /> <!-- AAW: SMCWAFA -->
					<xs:element name="mitplastiketikett" type="janein" nillable="true" /> <!-- AAW: SMCPLAET -->
					<xs:element name="unzulaessigefarbe1" type="char2" nillable="true" /> <!-- AAW: SMCFARB1 -->
					<xs:element name="unzulaessigefarbe1text" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="unzulaessigefarbe2" type="char2" nillable="true" /> <!-- AAW: SMCFARB2 -->
					<xs:element name="unzulaessigefarbe2text" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
				</xs:sequence>
			</xs:complexType>
		</xs:element>
		<xs:element name="plastiketiketten" minOccurs="1"
			maxOccurs="1">
			<xs:complexType>
				<xs:sequence>
					<xs:element name="anzahl" type="numc1" nillable="true" /> <!-- AAW: SMPLAETI -->
					<xs:element name="farbe1" type="char2" nillable="true" /> <!-- AAW: SMPFARB -->
					<xs:element name="farbe1text" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="farbe2" type="char2" nillable="true" /> <!-- AAW: SMPFA2 -->
					<xs:element name="farbe2text" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
				</xs:sequence>
			</xs:complexType>
		</xs:element>
		<xs:element name="zusatzmarkierungdraht" minOccurs="1"
			maxOccurs="2">
			<xs:complexType>
				<xs:sequence>
					<xs:element name="ringende" type="janein" nillable="true" /> <!-- ringende = N, dann ringanfang --> <!-- AAW: SMRINGEN -->
					<xs:element name="markierungsart" type="char2" nillable="true" /> <!-- AAW: neues Feld, aber abgeleitet u.a. von SMWFARBE -->
					<xs:element name="markierungsarttext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
					<xs:element name="farbe" type="char2" nillable="true" /> <!-- AAW: SMFARBE1 + SMFARBE2 -->
					<xs:element name="farbetext" type="char80" nillable="true" /> <!-- AAW: neues Feld -->
				</xs:sequence>
			</xs:complexType>
		</xs:element>
		<xs:element name="chargenstempel" type="janein" nillable="true" /> <!-- AAW: neues Feld, Ersatz für CSTMP -->
		<xs:element name="markierungstext" type="char1000" nillable="true" /> <!-- Generierter Gesamttext; war markierung --> <!-- AAW: CMARK und CAGTL*, wenn KUTEXT='MARK.' -->
	</xs:sequence>
</xs:complexType>

regards,

Adrian

Thanks for your response ? Any idea when the improvements would be released .?

No sooner than we release version 5.0. Maybe in 5.1.

To learn more about EasyMorph visit easymorph.com.