Jump to content
zua

SAFT FILE

Recommended Posts

zua

Bom dia a todos.

Tenho um problema ao criar o ficheiro Saft, e espero que alguém ja tenho feito isto e me possa ajudar, pois não tenho experiência em XML.

Estou a usar VB6 e consigo criar um ficheiro em XML, porém, não tenho a certeza de como adicionar o 'NameSpace' urn:OECD:StandardAuditFile-Tax:PT_1.03_01

ao fazer isto, o texto xmlns="" é automaticamente adicionado ao node <Header>.

Aqui esta o código que uso, e o resultado.

Set xmlDoc = New MSXML2.DOMDocument60
Dim pi As IXMLDOMProcessingInstruction

Set pi = xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding='Windows-1252'") 'encoding="UTF-8"

xmlDoc.insertBefore pi, xmlDoc.documentElement
Set xmlRootNode = xmlDoc.createElement("AuditFile")
xmlDoc.appendChild xmlRootNode

xmlDoc.documentElement.setAttribute "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"

xmlDoc.documentElement.setAttribute "xsi:schemaLocation", "urn:OECD:StandardAuditFile-Tax:PT_1.03_01 SAF-T-PT.XSD"
xmlDoc.documentElement.setAttribute "xmlns:doc", "urn:schemas-basda-org:schema-extensions:documentation"
xmlDoc.documentElement.setAttribute "xmlns", "urn:OECD:StandardAuditFile-Tax:PT_1.03_01"


//de seguida crio o node <header>

	Set xmlNodeLevel0 = xmlDoc.createElement("Header")
	xmlRootNode.appendChild xmlNodeLevel0
 

Resultado:

<?xml version="1.0" encoding="Windows-1252"?>
<AuditFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:OECD:StandardAuditFile-Tax:PT_1.03_01 SAF-T-PT.XSD" xmlns:doc="urn:schemas-basda-org:schema-extensions:documentation" xmlns="urn:OECD:StandardAuditFile-Tax:PT_1.03_01"><Header xmlns="">
 

Será que alguém com mais experiência se sabe explicar porque?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.