Delete Attribute in xml file

Mrinmay
Member Posts: 74
Hi Expert,
i have a xml file. the data is like below :
xml version="1.0" encoding="UTF-8" standalone="no" ?>
- <Envelope xmlns="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd" xmlns:edp="http://edavki.durs.si/Documents/Schemas/EDP-Common-1.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd">
- <edp:Header xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd">
- <edp:taxpayer>
<edp:taxNumber>77777777</edp:taxNumber>
<edp:taxpayerType>PO</edp:taxpayerType>
<edp:name>CRONUS International Ltd.</edp:name>
<edp:address1>5 The Ring</edp:address1>
<edp:address2>Westminster</edp:address2>
<edp:city>London</edp:city>
<edp:postNumber>1</edp:postNumber>
<edp:postName>London</edp:postName>
<edp:maticnaStevilka />
<edp:resident>true</edp:resident>
</edp:taxpayer>
<edp:responseTo />
<edp:domain />
</edp:Header>
<edp:Signatures xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd" />
- <body>
<edp:bodyContent xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd" />
- <DDV-O>
...............
.............
Now i want to delete the attribute in element <EDP:Header>(Bold portion). means i want to modify
<edp:Header xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd"> to <edp:Header> only.
i am using Automation.
Please help me to remove the attibute & let me know how to do it?
Thanx in advance.
Regards,
Mrinmay
i have a xml file. the data is like below :
xml version="1.0" encoding="UTF-8" standalone="no" ?>
- <Envelope xmlns="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd" xmlns:edp="http://edavki.durs.si/Documents/Schemas/EDP-Common-1.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd">
- <edp:Header xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd">
- <edp:taxpayer>
<edp:taxNumber>77777777</edp:taxNumber>
<edp:taxpayerType>PO</edp:taxpayerType>
<edp:name>CRONUS International Ltd.</edp:name>
<edp:address1>5 The Ring</edp:address1>
<edp:address2>Westminster</edp:address2>
<edp:city>London</edp:city>
<edp:postNumber>1</edp:postNumber>
<edp:postName>London</edp:postName>
<edp:maticnaStevilka />
<edp:resident>true</edp:resident>
</edp:taxpayer>
<edp:responseTo />
<edp:domain />
</edp:Header>
<edp:Signatures xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd" />
- <body>
<edp:bodyContent xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd" />
- <DDV-O>
...............
.............
Now i want to delete the attribute in element <EDP:Header>(Bold portion). means i want to modify
<edp:Header xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd"> to <edp:Header> only.
i am using Automation.
Please help me to remove the attibute & let me know how to do it?
Thanx in advance.
Regards,
Mrinmay
0
Comments
-
I am sure that you can use the XSLT to do that (transformation). But how, I do not know, but there are examples on web how to remove namespaces form the XML through the XSLT. May be you will be able to modify it to remove only the one attribute you need.0
-
If I remember rightly, you cannot delete elements / attributes inside a DOM document with the DOM methods using Navision Automation. You need to create a second DOM document and copy your XML structure without the attribute which you want to delete. Or use the xsd transformation.0
-
[Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kine wrote:I am sure that you can use the XSLT to do that (transformation). But how, I do not know, but there are examples on web how to remove namespaces form the XML through the XSLT. May be you will be able to modify it to remove only the one attribute you need.
Hi Kine,
Thank you for your reply. Can you please let me know how to do it with xslt? Is there any document which i can refer?
because i am not getting how to use xslt in Nav using automation.
Regards,
Mrinmay0 -
Hi, sorry I have not found any code for this anymore. Check this http://www.w3.org/DOM/faq.html at topic "How do I move a Node from one document to another?". You can use the importNode or (with Dom v3) the adoptNode to copy the relevant Nodes from you source XML in a new XML document.
You schould also try the removeAttributeNode method before. Maybe it works?!
On the other hand, if copying is the only solution and you don't want to waste time any more then keep it simple. Open the xml File as Textfile, search for the unwanted string xmlns:edp="http://edavki.durs.si/Documents/Schemas/DDV_O_7.xsd", delete it and replace the original file.
Maybe, I didn't tried it, you can do this manipulation inside a stream and then load the stream directly inside you XML document without the need to save it before on disk.0 -
Please have a look at Codeunit 403 Application Launch Management, Function LaunchApp, to see an example of how to do it programmatically from NAV.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