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 :
Microsoft Dynamics AX (Archived)

How i can generate this XML structure?

(0) ShareShare
ReportReport
Posted on by 578

Good day!

I need generate a xml structure but i ca't delete an attribute, this is my code.

<code>

XmlDocument cfdDocument;
XmlElement Complemento, Leyenda;
cfdDocument = new XmlDocument();

cfdDocument.createElement3("fiscal", "Fiscales", "http://");

Complemento = cfdDocument.createElement3("fiscal", "Fiscales", "http://");

Complemento.setAttribute('version',"1.0");

Leyenda = cfdDocument.createElement3("fiscal", "Leyenda", "http://");

Leyenda.setAttribute('texto',"Description....");
Leyenda.setAttribute('norma',"Norma...");
Leyenda.setAttribute('disposicion',"Disposicion....");

Complemento.appendChild(Leyenda);

</code>

And this is th output  XML

<fiscal:Fiscales version="1.0" xmlns:fiscal="http://">
<fiscal:Leyenda texto="Description...." norma="Norma..." disposicion="Disposicion...." />
</fiscal:Fiscales>

How i can delete this attribute xmlns:fiscal="http://"   ?? y try a string empty  createElement3("fiscal", "Leyenda", "") but it does not work

Thanks in advance.!!!!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Using a namespace prefix without actually defining the namespace (which is what you're doing by createElement3("fiscal", "Leyenda", "")) indeed doesn't make sense.

    If you don't want to specify any namespace, use createElement("Leyenda") instead.

  • ismaelivan Profile Picture
    578 on at

    Good day Martin, tyhanks for your answer.

    But now the output XML is

    <Fiscales version = "1.0">

    <Leyenda texto = "Descripción ...." norma = "Norma ..." disposicion = "Disposición ..." />

    </Fiscales>

    and I want the word fiscal to precede, ex. fiscal:Leyenda fiscal:Fiscal

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

    Unfortunately your two requirements contradict each other. You can't have a namespace prefix without defining a meaning of this prefix.

    What business problem are you trying to solve by these impossible technical requirements? If the business requirement is meaningful, we should be able to find a suitable technical solution. And if we find that the requirement makes no sense, you'll know that that problem to solve isn't in code...

  • ismaelivan Profile Picture
    578 on at

    You're right Martin, I already made it.
    This XML element is inside an XML document, so I didn't need the prefix here, it worked for me to place the same namespace of the main header, they looked like this:

    cfdDocument.createElement3("fiscal", "Fiscales", "http://www.sat.gob.mx/cfd/3");

    <xml>
    <encabezado xmlns:cfdi = "http://www.sat.gob.mx/cfd/3">
    .....
    <fiscal:Fiscales version =" 1.0 ">
    <fiscal:Leyenda texto="Descripción ...." norma="Norma ..." disposicion="Disposición ..." />
    </ fiscal:Fiscales>
    </encabezado>
    </xml>

    Gracias Martin 

  • ismaelivan Profile Picture
    578 on at

    Tks

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans