mibuso.com

Microsoft Business Solutions online community
It is currently Fri Apr 25, 2014 7:00 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [Solved] problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Thu Jun 17, 2010 11:04 pm 
Offline

Joined: Mon Jul 15, 2002 7:01 am
Posts: 11
Location: Norway
Country: Norway (no)
Hi all,

I'm using Navision 3.70. And are generating an xml-file like this:

START:
variable
Var Name DataType Subtype Length
Ja CurrNode Automation 'Microsoft XML, v4.0'.IXMLDOMNode
Name DataType Subtype Length
xmlInvoice Automation 'Microsoft XML, v4.0'.DOMDocument30
objPI Automation 'Microsoft XML, v4.0'.IXMLDOMProcessingInstruction


CREATE(xmlInvoice);
xmlInvoice.async := FALSE;
xmlInvoice.loadXML('<pidx:Invoice></pidx:Invoice>');

objPI := xmlInvoice.createProcessingInstruction('xml','version="1.0" encoding="ISO-8859-1"');
CurrNode := xmlInvoice.documentElement;
xmlInvoice.insertBefore(objPI,CurrNode);

xmlInvoice.documentElement.setAttribute('xmlns','http://www.api.org/pidXML/v1.0');
xmlInvoice.documentElement.setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
xmlInvoice.documentElement.setAttribute('xmlns:pidx','"http://www.api.org/pidXML/v1.0');
xmlInvoice.documentElement.setAttribute('xsi:schemaLocation',
'http://www.api.org/pidXML/v1.0 C:\PIDX\Invoice-2002-02-14-V1-0.xsd');
xmlInvoice.documentElement.setAttribute('pidx:transactionPurposeIndicator','Original');
xmlInvoice.documentElement.setAttribute('pidx:version','1.0');

CurrNode := xmlInvoice.documentElement;
END

Of course there's more code :),but my problem is the loadxml('<pidx:Invoice></pidx:Invoice>); it seems like it will not accept the : character. Everthing works fine if I use any other character, or just <pidx Invoice></Pidx Invoice>, without the : .

Does anyone have a clue how to solve this?

Regards
Bente


Last edited by bentee on Fri Jun 18, 2010 1:26 pm, edited 1 time in total.

Top
 Profile E-mail  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 12:04 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8986
Location: 3rd rock from sun
Country: United States (us)
I suggest to make a change in your code to the following.

xmlInvoice.loadXML('<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<pidx:Invoice></pidx:Invoice>');


and remove

objPI := xmlInvoice.createProcessingInstruction('xml','version="1.0" encoding="ISO-8859-1"');
CurrNode := xmlInvoice.documentElement;
xmlInvoice.insertBefore(objPI,CurrNode);

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 12:10 am 
Offline

Joined: Mon Jul 15, 2002 7:01 am
Posts: 11
Location: Norway
Country: Norway (no)
Thanks, but it's not working :cry: . It then get problems with the next line AddElement('xmlns','http://www.api.org/pidXML/v1.0'), and gives error
"This Automation variable has not been instantiated. You can instantiate it by either creating or assigning it"

Bent


Top
 Profile E-mail  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 12:20 am 
Offline

Joined: Mon Jul 15, 2002 7:01 am
Posts: 11
Location: Norway
Country: Norway (no)
It works fine if I don't use the prefix pidx: in front of Invoice...

Regards,
Bente


Top
 Profile E-mail  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 12:28 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8986
Location: 3rd rock from sun
Country: United States (us)
which line does it error and can you paste your new code?

Thanks.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 9:36 am 
Offline

Joined: Mon Jul 15, 2002 7:01 am
Posts: 11
Location: Norway
Country: Norway (no)
It gives error on the first setAttribute. I also tried to rearrange them, and leave some out, but it won't help.

CREATE(xmlInvoice);
xmlInvoice.async := FALSE;

xmlInvoice.loadXML('<?xml version="1.0" encoding="ISO-8859-1"?>' +
'<pidx:Invoice></pidx:Invoice>');

xmlInvoice.documentElement.setAttribute('xmlns','http://www.api.org/pidXML/v1.0');
xmlInvoice.documentElement.setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
xmlInvoice.documentElement.setAttribute('xmlns:pidx','http://www.api.org/pidXML/v1.0');
xmlInvoice.documentElement.setAttribute('xsi:schemaLocation',
'http://www.api.org/pidXML/v1.0 C:\PIDX\Invoice-2002-02-14-V1-0.xsd');
xmlInvoice.documentElement.setAttribute('pidx:transactionPurposeIndicator','Original');
xmlInvoice.documentElement.setAttribute('pidx:version','1.0');


CurrNode := xmlInvoice.documentElement;

thanks


Top
 Profile E-mail  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 12:36 pm 
Offline

Joined: Thu Sep 09, 2004 2:04 pm
Posts: 1075
Location: Switzerland
Country: Switzerland (ch)
Try this:
Code: Select all
// xmlProcessingInst: 'Microsoft XML, v6.0'.IXMLDOMProcessingInstruction
// CurrNode: 'Microsoft XML, v6.0'.IXMLDOMNode

CREATE(xmlInvoice);
xmlInvoice.async := FALSE;
xmlProcessingInst:= xmlInvoice.createProcessingInstruction('xml','version="1.0" encoding="ISO-8859-1"');
CurrNode := xmlInvoice.appendChild(xmlProcessingInst);
CurrNode := xmlInvoice.createElement('pidx:Invoice');
CurrNode := xmlInvoice.appendChild(CurrNode);

xmlInvoice.documentElement.setAttribute('xmlns','http://www.api.org/pidXML/v1.0');
xmlInvoice.documentElement.setAttribute('xmlns:xsi','http://www.w3.org/2001/XMLSchema-instance');
xmlInvoice.save('c:\temp\myFile.xml');


Hope this helps.
Thomas


Top
 Profile  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 1:25 pm 
Offline

Joined: Mon Jul 15, 2002 7:01 am
Posts: 11
Location: Norway
Country: Norway (no)
Oh, my, it worked!!!!! You really made my day!!! =D> =D> =D>

Thank you so much!!

Best regards,
Bente


Top
 Profile E-mail  
 
 Post subject: Re: problems with xmlDomDocument.loadXML('<pidx:Invoice/>')
PostPosted: Fri Jun 18, 2010 1:28 pm 
Offline

Joined: Thu Sep 09, 2004 2:04 pm
Posts: 1075
Location: Switzerland
Country: Switzerland (ch)
bentee wrote:
Oh, my, it worked!!!!! You really made my day!!! =D> =D> =D>

Thank you so much!!

Best regards,
Bente


Glad to help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: