Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Textattribute in XMLPort

(1) ShareShare
ReportReport
Posted on by 8

Hello,
I am trying to import using the following XML port:

xmlport 60100 MessageXMLPort
{
    Format = Xml;

    schema
    {
        textelement(Messages)
        {
            tableelement(Message; Message)
            {
                AutoUpdate = true;

                fieldelement("ID"; Message.ID)
                {
                }
                fieldelement("Sender"; Message.Sender)
                {
                    MinOccurs = Zero;
                }
                fieldelement("Recipient"; Message.Recipient)
                {
                    MinOccurs = Zero;
                    textattribute("Gender")
                    {
                        XmlName = 'gender';
                        Occurrence = Optional;
                        Unbound = true;
                    }
                }
                fieldelement("Subject"; Message.Subject)
                {
                    MinOccurs = Zero;
                }
                fieldelement("Body"; Message.Body)
                {
                    MinOccurs = Zero;

                }
                fieldelement("SentDate"; Message."Sent Date")
                {
                    MinOccurs = Zero;
                }
            }
        }
    


My file looks like this:

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<Messages>
  <Message>
    <ID>1</ID>
    <Sender gender="male">John Doe</Sender>
    <Recipient>jane.doe@example.com</Recipient>
    <Subject>Welcome!</Subject>
    <Body>Welcome to our platform.</Body>
    <SentDate isPostponed="true">09/01/24</SentDate>
  </Message>
  <Message>
    <ID>2</ID>
    <Sender gender="male">Sales Team</Sender>
    <Recipient>sales@company.com</Recipient>
    <Subject>Weekly Update</Subject>
    <Body>Please, find attached the weekly report.</Body>
    <SentDate isPostponed="false">09/08/24</SentDate>
  </Message>
  <Message>
    <ID>3</ID>
    <Sender>HR Department</Sender>
    <Recipient>hr@company.com</Recipient>
    <Subject>New Policies Update</Subject>
    <Body>We have updated the company's remote work policy.</Body>
    <SentDate>09/10/24</SentDate>
  </Message>
  <Message>
    <ID>4</ID>
    <Sender>Support Team</Sender>
    <Recipient>support@company.com</Recipient>
    <Subject>Support Ticket #12345</Subject>
    <Body>Your support ticket has been resolved.</Body>
    <SentDate>09/12/24</SentDate>
  </Message>
  <Message>
    <ID>5</ID>
    <Sender>John T. Doe</Sender>
    <Recipient>jane.doe@example.com</Recipient>
    <Subject>Follow-Up</Subject>
    <Body>Let me know if you have any further questions.</Body>
    <SentDate>09/14/24</SentDate>
  </Message>
</Messages>

I am receiving the error: "Imported XML cannot validate with the schema: The 'gender' attribute is not declared." What am I doing wrong with the attribute that it is not being recognized? (I know that I should also define the 'isPostponed' attribute, but I am trying to fix the gender one first). 

Thank you in advance!

  • Suggested answer
    Nyakinyua Profile Picture
    Nyakinyua 55 on at
    Textattribute in XMLPort
    The error you're encountering, "The 'gender' attribute is not declared," happens because you’ve defined the gender attribute in your XML port for the Recipient field, but in the XML file, the gender attribute is actually part of the Sender field, not the Recipient field.

    You need to move the gender attribute definition in the XML port to the Sender field, where it actually appears in the XML file.
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 4,744 on at
    Textattribute in XMLPort
    Hope this helps: https://yzhums.com/4809/

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans