Anonymous
Not applicable
2016-02-27
06:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] tXmlMap Find node based on attribute value
I'm not very familiar with XML. I've been using tXmlMap to parse a response coming from a tRestClient into a database.
There is an array within the xml that contains multiple values I need to include. Everything else maps across just fine, no problem.
We have a couple custom fields that the attribute "name" determines what the custom field is. I need to be able to extract both the "job number" and "customer name" into a CSV output. I don't think this is a loop since i need both custom_fields.
How do I structure the document so I can pull out both? Should I be using a different component than a tXmlMap?
XML Structure
<issue>
<id>7774</id>
<project id="106" name="Data Management"/>
<tracker id="1" name="Bug"/>
<status id="7" name="Backlog"/>
<priority id="2" name="Normal"/>
<author id="60" name="Steven Baer"/>
<parent id="7773"/>
<subject>Subtask1</subject>
<description></description>
<start_date>2016-02-27</start_date>
<due_date/>
<done_ratio>0</done_ratio>
<is_private>false</is_private>
<estimated_hours/>
<custom_fields type="array">
<custom_field id="1" name="Job Number">
<value>25735</value>
</custom_field>
<custom_field id="2" name="Company Name">
<value>Test Company 1</value>
</custom_field>
</custom_fields>
<created_on>2016-02-27T10:13:45Z</created_on>
<updated_on>2016-02-27T10:13:45Z</updated_on>
<closed_on/>
</issue>
Trying to output to:
Id, CompanyName, ProjectName, ProjectId, JobNumber, Subject, Description, AuthorId, AuthorName, etc.
7774, Test Company 1, Data Management, 106, 25735, Subtask1, , 60, Steven Baer
There is an array within the xml that contains multiple values I need to include. Everything else maps across just fine, no problem.
We have a couple custom fields that the attribute "name" determines what the custom field is. I need to be able to extract both the "job number" and "customer name" into a CSV output. I don't think this is a loop since i need both custom_fields.
How do I structure the document so I can pull out both? Should I be using a different component than a tXmlMap?
XML Structure
<issue>
<id>7774</id>
<project id="106" name="Data Management"/>
<tracker id="1" name="Bug"/>
<status id="7" name="Backlog"/>
<priority id="2" name="Normal"/>
<author id="60" name="Steven Baer"/>
<parent id="7773"/>
<subject>Subtask1</subject>
<description></description>
<start_date>2016-02-27</start_date>
<due_date/>
<done_ratio>0</done_ratio>
<is_private>false</is_private>
<estimated_hours/>
<custom_fields type="array">
<custom_field id="1" name="Job Number">
<value>25735</value>
</custom_field>
<custom_field id="2" name="Company Name">
<value>Test Company 1</value>
</custom_field>
</custom_fields>
<created_on>2016-02-27T10:13:45Z</created_on>
<updated_on>2016-02-27T10:13:45Z</updated_on>
<closed_on/>
</issue>
Trying to output to:
Id, CompanyName, ProjectName, ProjectId, JobNumber, Subject, Description, AuthorId, AuthorName, etc.
7774, Test Company 1, Data Management, 106, 25735, Subtask1, , 60, Steven Baer
295 Views