XmlToRecordlist conversion

XmlToRecordlist conversion

  
Hello,

When i convert the xml to a recordlist form using the XmlRecords_v1.xif extension,  it convert only the first record.
for example below is my xml format
<Part>
<id>1</id>
<name>test1</name>
<id>2</id>
<name>test2</name>
</Part>

the result i am getting as recordlist  is,  1, test1 with length 1

Can you please help me on this, i need to get all the records.

Thanks
Hi Shyn,

Well, if you are creating a data structure on XML to represent a list, I would assume you would clearly separate the different records.

I am going to indent your XML for the sake of demonstrating my recommendation:

<Part>
   <id>1</id>
   <name>test1</name>
   <id>2</id>
   <name>test2</name>
</Part>


I can see why this is being parsed as a single record. You would probably want to try something like:

<Part>
   <Record>
      <id>1</id>
      <name>test1</name>
   </Record>
   <Record>
      <id>2</id>
      <name>test2</name>
   </Record>
</Part>


or

<Part>
   <id>1</id>
   <name>test1</name>

</Part>
<Part>
   <id>2</id>
   <name>test2</name>
</Part>


if you don't need to have a root element, and if the extension supports it (which I'm not sure it does).

As you can see, in either example you do have two clearly defined sub-structures, one for each record. Notice, also, that the names are completely ficticious, and you do not need to call them "Record" :) Also, I indented the text to make it easier to read, but it can also be formatted the way you wrote it the first time around, all left-justified.

I hope this helps.

Regards,

Paulo Tavares
Hi Paulo,
 
Thanks for your reply.
 
I have tried with below xml format
 
<Part>
   <Record>
      <id>1</id>
      <name>test1</name>
   </Record>
   <Record>
      <id>2</id>
      <name>test2</name>
   </Record>
</Part>

 
But it’s not working. I am getting the record list with length is 1, but the id and name filed have null values, may be because the record definition does not match.
I have attached the oml fle.

Thanks

Hi Shyn,

Thank you very much for your reply, and for testing my suggestion.

I did look into the eSpace, and I didn't see much wrong there. However, since I do not have the required extensions, I wasn't able to publish it locally.

However, if that's the case, I would suggest you to try the following structure:

<Part>
   <id>1</id>
   <name>test1</name>

</Part>
<Part>
   <id>2</id>
   <name>test2</name>
</Part>


And check if it works better. It should.

I never worked with that specific extension, so it would all boil down to the way it parses the XML, but from your description of the results, this should work.

Let me know how it goes.

Regards,

Paulo Tavares

Hi Shyn,

Indeed the second example Paulo gave will not work either because it is not a valid xml document. It must have one and only one root element. For XmlRecords (the latest version of the extension) to understand it it should be surrounded with <RecordList> so it would be something like the one below, and have when you invoke XmlToRecordList set the BypassRootRecordListNode input parameter to true:

<RecordList>
  <Part>
     <id>1</id>
     <name>test1</name>

  </Part>
  <Part>
     <id>2</id>
     <name>test2</name>
  </Part>

</RecordList>

Attached your example with this change. It is working with the latest XmlRecords extension version
Oh, shame on me :|

That is indeed closer to my first recommendation:

<Part>
   <Record>
      <id>1</id>
      <name>test1</name>
   </Record>
   <Record>
      <id>2</id>
      <name>test2</name>
   </Record>
</Part>


I didn't know, however, that the root node needed to be "RecordList" :)

Thanks for the tip Gonçalo.

Regards,

Paulo Tavares



Thanks muchGonçalo and Paulo
I have a quick question on this, as i am not that familiar with the XmlToRecordList extension and I am trying to use it. In the example Goncalo provided, Gocalo is using "item" for the Attribute Prefix, but i dont see that enywhere in the code, how would you use the Attribute Prefix?
Also, i tried your example, and get the error below, same error i am getting when trying to parse my xml. Any help would be appreciated. Could this be because we are versions behinde? version 5.1?

"The current node (RecordList) does not match the record definition (Part)"

Thanks!
Karin
Agreed wiht Karin !.. i am also getting the same issue while parsing the XML :

"The current node (Part) does not match the record definition ()"

Any Idea ?
Leo - could you perhaps share more details, eventually an example, so we can have a look at it? Thanks!
Hi Mario,
thanks for the reply.. i am just having a query fired to get all user details : Select * from users.
result is in a structure named Users which has a definition of Users table.
 
i am using the extension xml records to convert Recordlist to Xml but while converting xml to Recordlist(Recordlist having Users table definition), i m getting the error.
The current node (Users) does not match the record definition ()



Hi Leo,

You should be deserializing to a List of Records (with a User record in it), instead of a List of Users. 

That's a current limitation of this component, sorry.

Check the attached example module (XML_Users.oml)
Watch out, as it dumps your entire users & passwords to an xml/screen that has no authentication... 




Thanks Goncalo for the solution ..i was using List of Users.. and was bitting around the bush.. Dammn..

Thanks again for the help ! you are the MAN !.