Question

Below is my XML file

<?xml version="1.0" encoding="ISO-8859-1"?>
 <DataResult>
  <Data>
   <Name lang="eng">Reshma</Name>
   <Birth Date>1988-09-23T00:00:00</Birth Date>
  </Data>
 <Data>
   <Name lang="eng">Rahul</Name>
   <Birth Date>1991-09-23T00:00:00</Birth Date>
 </Data>
</DataResult>

I am trying to read this XML node value into the for each loop container, below is the my for each loop container setting,

enter image description here

Now I want to read that Name node value from above XML file and enter that value into database, can't I take a single variable first read the first Name node value into it and update the database and again rewrite the same variable by another Name node and update the database, since my main xml file is going to have n numbers of Name node.

My main aim is to read the xml file node into foreach loop, tried lot for it but unable to get the solution, any help will be greatly appreciated.

Was it helpful?

Solution

Here's a possible solution which may be dodging the actual question.

Like I mentioned in the comments, I dont think you actually need the "foreach container". Use The "XML Source" to directly import all of your data. Next, as per your "DT_WSTR" error I would advise you to use either a "Data Conversion" or a "Derived Column" component to add a maximum length to your Columns.

enter image description here

Finally, you can use the "OLE DB Destination" if you are inserting the data into a table. I was under the impression that you wanted to update some existing data, in which case, I have always used an "OLE DB Command" with an UPDATE statement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top