XMLPort for this XML File...
ebsoft
Member Posts: 81
Hi everybody,
can you help me creating an XMLPort object based on this XML File?
I have already created the NAV Table in which the data goes on.
Here is the table:
And here is the XML File (I've already removed namespace):
I actually get an error stating that <schema> is not expected or something similar.
Thank you very much in advance.
Federico
I've found a mate who helped me.
Thank you anyway.
can you help me creating an XMLPort object based on this XML File?
I have already created the NAV Table in which the data goes on.
Here is the table:
Enabled Field No. Field Name Data Type Length Description Yes 1 Data Code 10 Yes 2 Mercato Code 10 Yes 3 Ora Integer Yes 4 PUN Decimal Yes 5 Nord Decimal
And here is the XML File (I've already removed namespace):
<?xml version="1.0" encoding="UTF-8" ?>
<NewDataSet>
<schema id="NewDataSet">
<element name="NewDataSet" IsDataSet="true" UseCurrentLocale="true">
<complexType>
<choice minOccurs="0" maxOccurs="unbounded">
<element name="Prezzi">
<complexType>
<sequence>
<element name="Data" type="xs:string" minOccurs="0" />
<element name="Mercato" type="xs:string" minOccurs="0" />
<element name="Ora" type="xs:string" minOccurs="0" />
<element name="PUN" type="xs:string" minOccurs="0" />
<element name="NAT" type="xs:string" minOccurs="0" />
<element name="CALB" type="xs:string" minOccurs="0" />
<element name="CNOR" type="xs:string" minOccurs="0" />
<element name="CSUD" type="xs:string" minOccurs="0" />
<element name="NORD" type="xs:string" minOccurs="0" />
<element name="SARD" type="xs:string" minOccurs="0" />
<element name="SICI" type="xs:string" minOccurs="0" />
<element name="SUD" type="xs:string" minOccurs="0" />
<element name="AUST" type="xs:string" minOccurs="0" />
<element name="BRNN" type="xs:string" minOccurs="0" />
<element name="COAC" type="xs:string" minOccurs="0" />
<element name="CORS" type="xs:string" minOccurs="0" />
<element name="E_CO" type="xs:string" minOccurs="0" />
<element name="E_NE" type="xs:string" minOccurs="0" />
<element name="E_NW" type="xs:string" minOccurs="0" />
<element name="E_SD" type="xs:string" minOccurs="0" />
<element name="FOGN" type="xs:string" minOccurs="0" />
<element name="FRAN" type="xs:string" minOccurs="0" />
<element name="GREC" type="xs:string" minOccurs="0" />
<element name="MFTV" type="xs:string" minOccurs="0" />
<element name="PRGP" type="xs:string" minOccurs="0" />
<element name="ROSN" type="xs:string" minOccurs="0" />
<element name="SLOV" type="xs:string" minOccurs="0" />
<element name="SVIZ" type="xs:string" minOccurs="0" />
<element name="TBRV" type="xs:string" minOccurs="0" />
<element name="PBNF" type="xs:string" minOccurs="0" />
</sequence>
</complexType>
</element>
</choice>
</complexType>
</element>
</schema>
<Prezzi>
<Data>20080519</Data>
<Mercato>MGP</Mercato>
<Ora>1</Ora>
<PUN>70,138844</PUN>
<NAT>62</NAT>
<CALB>60,77</CALB>
<CNOR>60,77</CNOR>
<CSUD>60,77</CSUD>
<NORD>60,77</NORD>
<SARD>75,12</SARD>
<SICI>198</SICI>
<SUD>60,77</SUD>
<AUST>0</AUST>
<BRNN>60,77</BRNN>
<COAC>75,12</COAC>
<CORS>75,12</CORS>
<E_CO>75,12</E_CO>
<E_NE>60,77</E_NE>
<E_NW>60,77</E_NW>
<E_SD>60,77</E_SD>
<FOGN>60,77</FOGN>
<FRAN>0</FRAN>
<GREC>0</GREC>
<MFTV>60,77</MFTV>
<PRGP>198</PRGP>
<ROSN>60,77</ROSN>
<SLOV>0</SLOV>
<SVIZ>0</SVIZ>
<TBRV>60,77</TBRV>
</Prezzi>
<Prezzi>
<Data>20080519</Data>
<Mercato>MGP</Mercato>
<Ora>2</Ora>
<PUN>45,049720</PUN>
<NAT>41,96</NAT>
<CALB>37,96</CALB>
<CNOR>37,96</CNOR>
<CSUD>37,96</CSUD>
<NORD>37,96</NORD>
<SARD>37,96</SARD>
<SICI>152</SICI>
<SUD>37,96</SUD>
<AUST>0</AUST>
<BRNN>37,96</BRNN>
<COAC>37,96</COAC>
<CORS>37,96</CORS>
<E_CO>37,96</E_CO>
<E_NE>37,96</E_NE>
<E_NW>37,96</E_NW>
<E_SD>37,96</E_SD>
<FOGN>37,96</FOGN>
<FRAN>0</FRAN>
<GREC>0</GREC>
<MFTV>37,96</MFTV>
<PRGP>152</PRGP>
<ROSN>37,96</ROSN>
<SLOV>0</SLOV>
<SVIZ>0</SVIZ>
<TBRV>37,96</TBRV>
</Prezzi>
</NewDataSet>
I actually get an error stating that <schema> is not expected or something similar.
Thank you very much in advance.
Federico
I've found a mate who helped me.
Thank you anyway.
0
Answers
-
The problem is that the Schema of the XML is part of the XML. Nav is not able to work with that and you will need to go around that in some way.0
-
Could you post for us how did you solved your problem? We are very curious people there... 8)0
-
I had to work with an xml file that had a junk line that Navision would not accept, so I ran the file through Instream, changed the bad line and then moved the file to a temp file and then sent the temp file to the xmlport:
InFile.CREATEINSTREAM(IStream);
IStream.READTEXT(firstLine); ///first line is ok
Tempfile.WRITE(firstLine);
IStream.READTEXT(firstLine);
Tempfile.WRITE('<OrderLog>'); ///this line has junk so change tag
WHILE NOT (IStream.EOS()) DO
BEGIN
IStream.READTEXT(firstLine);
Tempfile.WRITE(firstLine);
END;
Tempfile.CREATEINSTREAM(IStream);
CLEAR(XML);
XML.SETSOURCE(IStream);
XML.IMPORT;0 -
kine wrote:Could you post for us how did you solved your problem? We are very curious people there... 8)
Hope you were talking to me...
I've used a function used elsewhere in NAV:RemoveNamespace(XMLSourceDocument : Automation "'Microsoft XML, v4.0'.DOMDocument40";VAR XMLDestinationDocument : Automation "'Microsof TempTable.Picture.CREATEOUTSTREAM(OutStreamStylesheet); TempTable.Picture.CREATEINSTREAM(InStreamStylesheet); WITH OutStreamStylesheet DO BEGIN WRITETEXT('<?xml version="1.0" encoding="UTF-8"?>'); WRITETEXT('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">'); WRITETEXT('<xsl:output method="xml" encoding="UTF-8" />'); WRITETEXT('<xsl:template match="/">'); WRITETEXT('<xsl:copy>'); WRITETEXT('<xsl:apply-templates />'); WRITETEXT('</xsl:copy>'); WRITETEXT('</xsl:template>'); WRITETEXT('<xsl:template match="*">'); WRITETEXT('<xsl:element name="{local-name()}">'); WRITETEXT('<xsl:apply-templates select="@* | node()" />'); WRITETEXT('</xsl:element>'); WRITETEXT('</xsl:template>'); WRITETEXT('<xsl:template match="@*">'); WRITETEXT('<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>'); WRITETEXT('</xsl:template>'); WRITETEXT('<xsl:template match="text() | processing-instruction() | comment()">'); WRITETEXT('<xsl:copy />'); WRITETEXT('</xsl:template>'); WRITETEXT('</xsl:stylesheet>'); END; IF ISCLEAR(XMLStyleSheet) THEN IF NOT CREATE(XMLStyleSheet) THEN EXIT(FALSE); IF NOT XMLStyleSheet.load(InStreamStylesheet) THEN EXIT(FALSE); IF ISCLEAR(XMLDestinationDocument) THEN IF NOT CREATE(XMLDestinationDocument) THEN EXIT(FALSE); XMLSourceDocument.transformNodeToObject(XMLStyleSheet,XMLDestinationDocument); EXIT(TRUE);
This removed xs schema that NAV does not like very much.
So I could import correctly the XML file in my Table.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
- 322 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
