Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
MZein
Contributor III
Contributor III

.item file

Hi All

I am searching for a fast solution for the problem of generating metadata from .item file. The problem is that this file has multiple loops  so how we can  parse this file

Best Regards 

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

OK, this requires an extra step. The whole job looks like this....

 

0683p000009M7Ox.png

 

Adding environments puts another loop into the equation. So you start off with the tFileInputXML configured as below.....

0683p000009M7rb.png

 

You then add a tExtractXMLField and configure as below....

0683p000009M7rg.png

 

Essentially you get the environment (env) and the sub-XML (context) from the first component. You then use the context column to extract further details (per environment) from the tExtractXMLField component. This loops on "/context/contextParameter", passes the "env" field through without any config, then extracts the "name" and "value". 

 

If you try this, it will return what you need

 

View solution in original post

7 Replies
Anonymous
Not applicable

What exactly are you looking for in the .items file? You might not have to search all of the loops. This is essentially an XML file and if you know what you are looking for, you should be able to go straight to it

MZein
Contributor III
Contributor III
Author

Thank you for your interaction

I want to read the fields context and for each context I want to retrieve contexParameters next I want to save it in a text file. I tried tXMLMAP but it needs the schema of .item file


item.PNG
Anonymous
Not applicable

You can do this using the tFileInputXML or tExtractXMLField component. The image below demonstrates how to do this using the tFileInputXML component....

 

0683p000009M7Xh.png

MZein
Contributor III
Contributor III
Author

Thank you very much for this replay BUT I want also to retrieve the environment name which is located at <contaxt     name=.....> along with the name and value of each contextpearameter

 

Anonymous
Not applicable

OK, this requires an extra step. The whole job looks like this....

 

0683p000009M7Ox.png

 

Adding environments puts another loop into the equation. So you start off with the tFileInputXML configured as below.....

0683p000009M7rb.png

 

You then add a tExtractXMLField and configure as below....

0683p000009M7rg.png

 

Essentially you get the environment (env) and the sub-XML (context) from the first component. You then use the context column to extract further details (per environment) from the tExtractXMLField component. This loops on "/context/contextParameter", passes the "env" field through without any config, then extracts the "name" and "value". 

 

If you try this, it will return what you need

 

MZein
Contributor III
Contributor III
Author

Fantastic very nice this what I need. If you can give me more details about this solution or the logic behind it I will be very thankful

Best Regards

Anonymous
Not applicable

Essentially it is all to do with extracting data from looping XML. The items file I was working with is a bit big to include here, so I will just include the context variable section....

<context confirmationNeeded="false" name="Default">
    <contextParameter comment="" name="rich" prompt="rich?" promptNeeded="false" type="id_String" value="cdvdc"/>
    <contextParameter comment="" name="new1" prompt="new1?" promptNeeded="false" type="id_String" value="sdwf"/>
    <contextParameter comment="" name="new2" prompt="new2?" promptNeeded="false" type="id_String" value="scsfs"/>
    <contextParameter comment="" name="new3" prompt="new3?" promptNeeded="false" type="id_String" value="fwd"/>
  </context>
  <context confirmationNeeded="false" name="dev">
    <contextParameter comment="" name="rich" prompt="rich?" promptNeeded="false" type="id_String" value="ghgh"/>
    <contextParameter comment="" name="new1" prompt="new1?" promptNeeded="false" type="id_String" value="2323"/>
    <contextParameter comment="" name="new2" prompt="new2?" promptNeeded="false" type="id_String" value="wdce"/>
    <contextParameter comment="" name="new3" prompt="new3?" promptNeeded="false" type="id_String" value="2erfe"/>
  </context>
  <context confirmationNeeded="false" name="prod">
    <contextParameter comment="" name="rich" prompt="rich?" promptNeeded="false" type="id_String" value="ssss"/>
    <contextParameter comment="" name="new1" prompt="new1?" promptNeeded="false" type="id_String" value="fde"/>
    <contextParameter comment="" name="new2" prompt="new2?" promptNeeded="false" type="id_String" value="wds"/>
    <contextParameter comment="" name="new3" prompt="new3?" promptNeeded="false" type="id_String" value="wdewdf"/>
  </context>

The code in red is the outer looping section. You will see there are 3 repeating blocks. This is where we get the environment AND the contextParameter sections which are directly related to the environment. The green sections are the loops within the environment loops. Remember that the environment is only listed on the loop outside this. Therefore, when the first component retrieves the environment, the environment and the block of nested XML inside that loop is sent to the tExtractXMLField component. This will loop for each of the contextParameter elements within the block of XML passed to it.