Here is some code that we are using to read XML. Main thing is research the
XMLDocument, it is Microsoft xml component and there are tons of examples
out there on how to use it.
XMLDocument doc;
XMLNode rootNode, FileNode, GroupNode, OrderNode;
XMLNodeList ordersList, orderItemsList;
XMLParseError xmlError;
;
doc = new XMLDocument();
doc.async(FALSE);
doc.load(xmlFileNameAndPath);
xmlError = doc.parseError();
if (xmlError && xmlError.errorCode() != 0)
{
keepgoing=false;
currentError='XML Error: ' + xmlerror.toString();
currentFFHKey=-99;
throw error(currentError);
}
rootNode = doc.documentElement();
if (rootNode.baseName()=='PTNSalesOrderXSD')
{
totalOrdersForFile = rootNode.childNodes().length();
for (i = 0; i < rootNode.childNodes().length(); i++)
{
if
(rootNode.childNodes().item(i).baseName()=='SalesOrder')
{
try
{
OrderNode=rootNode.childNodes().item(i);
this.ProcessOrder(OrderNode);
successfulOrders++ ;
}
catch
{
failedOrders++ ;
ptnFFImportFiles_Errors.clear();
ptnFFImportFiles_Errors.initValue();
ptnFFImportFiles_Errors.initFromptnFFImportSO(this);
ptnFFImportFiles_Errors.insert();
continue;
}
}
else
{
keepgoing=false;
currentError='XML Order Error: BaseNameError=' +
rootNode.childNodes().item(i).baseName();
throw error(currentError);
}
}
}
else
{
keepgoing=false;
currentError='XML Not Sales Order Error: BaseNameError=' +
rootNode.baseName();
throw error(currentError);
}
}
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of tavocol2002
Sent: Tuesday, July 15, 2008 11:49 AM
To: [email protected]
Subject: [development-axapta] READ A CUSTOM XML
Hello to everybody.
Right now i have to read a XML generated by a server. The problem is
that i have writed many codes to create a XML but not for read a XML file.
This is a code example of the XML that i have to read. Thank you very
much to the people that reads this post.
<?xml version="1.0" encoding="UTF-8"?>
<eanucc:envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:eanucc="http://www.uc-council.org/smp/schemas/eanucc"
xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg"
xsi:schemaLocation="http://www.uc-council.org/smp/schemas/eanucc
As2Envelope.xsd http://www.uc-council.org/smp/schemas/eanucc
Transaction.xsd http://www.uc-council.org/smp/schemas/eanucc
DocumentCommand.xsd http://www.uc-council.org/smp/schemas/eanucc
Order.xsd http://www.uc-council.org/smp/schemas/fmcg
FmcgIdentification.xsd" communicationVersion="1.0">
<messageHeader creationDate="2008-07-07T00:00:00">
<userId>CEN</userId>
<password>PEDIDOS</password>
<messageIdentifier>23-287101</messageIdentifier>
<to>
<gln>7707205148881</gln>
</to>
<from>
<gln>7707185370005</gln>
</from>
<representingParty>
<gln>NORMANETCEN01</gln>
</representingParty>
</messageHeader>
<body>
<eanucc:transaction>
<entityIdentification>
<uniqueCreatorIdentification>23-287101</uniqueCreatorIdentification>
<contentOwner>
<gln>7707185370005</gln>
</contentOwner>
</entityIdentification>
<command>
<eanucc:documentCommand>
<documentCommandHeader type="ADD">
<entityIdentification>
<uniqueCreatorIdentification>23-287101</uniqueCreatorIdentification>
<contentOwner>
<gln>7707185370005</gln>
</contentOwner>
</entityIdentification>
</documentCommandHeader>
<documentCommandOperand>
<eanucc:order documentStatus="ORIGINAL"
creationDate="2008-07-07T00:00:00">
<paymentTerms type="DISCOUNT" eventType="DATE_INVOICE_RECEIVED">
<netPayment>
<timePeriodDue type="DAYS">60</timePeriodDue>
</netPayment>
</paymentTerms>
<movementDate>2008-07-07</movementDate>
<movementDateType>REQUESTED_PICKUP</movementDateType>
<typedEntityIdentification entityType="ORDER">
<entityIdentification>
<uniqueCreatorIdentification>23-287101</uniqueCreatorIdentification>
<contentOwner>
<gln>7707185370005</gln>
</contentOwner>
</entityIdentification>
</typedEntityIdentification>
<buyer>
<gln>7707185370005</gln>
</buyer>
<seller>
<gln>7707205148881</gln>
</seller>
<shipParty identificationType="SHIP_TO">
<gln>7707185370234</gln>
</shipParty>
<lineItem number="1">
<netPrice>
<amount currencyISOcode="">1,530.00</amount>
</netPrice>
<requestedQuantity>50</requestedQuantity>
<itemIdentification>
<gtin>7707205141677</gtin>
</itemIdentification>
</lineItem>
</eanucc:order>
</documentCommandOperand>
</eanucc:documentCommand>
</command>
</eanucc:transaction>
</body>
</eanucc:envelope>
THANK YOU VERY MUCH :D
Gustavo Camargo Téllez
Bogotá - Colombia
[Non-text portions of this message have been removed]