XMLports issue

joeymanson
Member Posts: 13
Greetings,
With XMLports, how can I define that an element is to be printed, more than once, depending of the number of relations on other table?
Example:
(...)
<name> [1,1]
<idNumber> [1,1]
<comment> [0,n]
(...)
the element <comments> needs to be filled from another table where the comments are defined (for instance by idNumber table key).
The desirable result of the genarated file is:
(...)
<name>John Smith</name>
<idNumber>9999999</idNumber>
<comment>comment 1</comment>
<comment>comment 2</comment>
<comment>comment 3</comment>
(...)
Anyone can help me please??
Thank you very much!!
With XMLports, how can I define that an element is to be printed, more than once, depending of the number of relations on other table?
Example:
(...)
<name> [1,1]
<idNumber> [1,1]
<comment> [0,n]
(...)
the element <comments> needs to be filled from another table where the comments are defined (for instance by idNumber table key).
The desirable result of the genarated file is:
(...)
<name>John Smith</name>
<idNumber>9999999</idNumber>
<comment>comment 1</comment>
<comment>comment 2</comment>
<comment>comment 3</comment>
(...)
Anyone can help me please??
Thank you very much!!

0
Comments
-
You can indent elements in an XMLport similar to how you would indent dataitems in a report. You have to set the LinkTable and LinkFields properties of the indentet element.0
-
Hi and thx for your reply,
The problem is that the elements <comment> cant be idented.
the only thing that i am able to do is something like:
<comments>
--<comment>comment 1</comment>
</comments>
<comments>
--<comment>comment 2</comment>
</comments>
where tag <comments> is defined as the table of comments with linktable and linkfields related by idNumber of the table of Persons, and comment defined as the field comment of table comments.
The struture i need to follow is
<comment>comment 1</comment>
<comment>comment 2</comment>
This way, where do i have to define the comment table and link fields without identation?
I hope you understand what my problem is
Thank you very much0 -
I think this is a limitation with the Xml designer, that you need to indent elements to loop subordinate records. Maybe you could solve your problem using XmlDom, but I haven't tried this myself. However, maybe this post can help you;
http://www.mibuso.com/forum/viewtopic.p ... xml+indent0 -
Yeah, I would suggest making all that you can through a XMLport then add whatever you cannot in Nav with XMLDom (as Nagi suggested)
edit: let us know if you need any help combining the two0 -
Nagi wrote:I think this is a limitation with the Xml designer, that you need to indent elements to loop subordinate records. Maybe you could solve your problem using XmlDom, but I haven't tried this myself. However, maybe this post can help you;
http://www.mibuso.com/forum/viewtopic.p ... xml+indent
This problem is similar to mine but not quite the same.
the diference is that i dont have a parent node to be defined as table. It seems to me that i would need the same element to be defined as table and field :shock:
<parentNode>
--<name>John Smith</name> [field of table of Persons]
--<idNumber>9999</idNumber> [field of table of Persons]
--<comment>comment 1<comment> [field of table of Comments]
--<comment>comment 2<comment> [field of table of Comments]
--(...)
</parentNode>
where comment 1 and comment 2 are comments in a table of comments linked by idNumber.
Table Persons -> key = idNumber
Table Comments -> key = idNumber,Comment
Is this possible with XMLports? If not, is there a way to do this with XMLDom?
Thx a lot all!!0 -
Yeah it appears (without seeing the rest of the XML document you're working with) you wont be able to accomplish your goal solely through XMLports.
Yes you can accomplish this through XMLports + XMLDom. (I suppose you overlooked what I said right above your latest post)
0 -
Xypher wrote:Yeah it appears (without seeing the rest of the XML document you're working with) you wont be able to accomplish your goal solely through XMLports.
Yes you can accomplish this through XMLports + XMLDom. (I suppose you overlooked what I said right above your latest post)
Hi there!
Hi didnt overlooked your last post Xypher, i just wanted to be certain you got my idea
So, can you give me any help on how i could to that?
convert the XML generated by my XMLPort
<name>John Smith</name>
<comments>
--<comment>comment 1</comment>
<comments>
<comments>
--<comment>comment 2</comment>
</comments>
(...)
to
<name>John Smith</name>
<comment>comment 1</comment>
<comment>comment 2</comment>
(...)
Thx a lot one more time!0 -
It's real easy to do...
{ (X = whichever version you have, hopefully 5+) xmlDom Automation 'Microsoft XML, vX.0'.DOMDocument xmlDomRootElement Automation 'Microsoft XML, vX.0'.IXMLDOMElement xmlDomNewElement Automation 'Microsoft XML, vX.0'.IXMLDOMElement DataRec Record 'Your Data Table' CommentRec Record 'Your Comment Table' BlobRec Record TempBlob BlobOut OutStream BlobIn InStream (Of course set BlobRec as Temporary) } BlobRec.Blob.CREATEINSTREAM(BlobIn); BlobRec.Blob.CREATEOUTSTREAM(BlobOut); DataRec.SETFILTER(blahblahblahblah); XMLPORT.EXPORT(XMLPORT::"Your XMLport", BlobOut, DataRec); IF ISCLEAR(xmlDom) THEN CREATE(xmlDom); xmlDom.load(BlobIn); xmlDomRootElement := xmlDom.documentElement; CommentRec.SETFILTER(DataRecLinkingFilters); IF CommentRec.FINDFIRST THEN REPEAT xmlDomNewElement := xmlDom.createNode('element','comment',''); xmlDomNewElement.Text := CommentRec.Comment; xmlDomRootElement.appendChild(xmlDomNewElement); CLEAR(xmlDomNewElement); //Probably don't need this but threw this in for good measure. UNTIL CommentRec.NEXT = 0; //xmlDom.save('C:\Documents And Settings\joeymanson\Desktop\XMLtest.xml');
Let me know if you have any difficulties with this.
Cheers!0 -
Thx a lot!
I will try it soon!
Then, i come here to tell you something...0 -
It looks like the file im trying to generate, is not possible to do with the help of XMLPorts
I think i'll have to generate my whole XML file through code.
Can you guys direct me to a nice NAV XMLDom Tutorial please?
Thx!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions