web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to add two root nodes in XML using x++

(0) ShareShare
ReportReport
Posted on by 152

I need to create the following

<Document>

<Cstr>

<Book>

<name>test</name>

</Book>

<Book>

<name>test</name>

</Book>

</cstr>

</Document>

How do I get </cstr>??

Can you help me with the code for the same??

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    XML documents can have only one root node, that's defined in the XML standard.

    If your XML file has many <Document> elements, you can add <Documents> root node and put all <Document> elements as child nodes of <Documents>.

    You also asked "How do I get </cstr>?" What do you mean by that?

  • Verified answer
    Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Cstr isn't a root node - it's embedded in the Document node. Or it would if the opening tag matched the closing one. It doesn't because the closing tag doesn't start with the capital 'C'.

    By the way, the structure will be obvious if you use indentation (see below). You can achieve that by using Insert > Insert Code (in the rich formatting view), therefore please use that for pasting code snippets.

    	
    		
    			test
    		
    		
    			test
    		
    	
    

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans