Skip to main content

Read xml file with namespace


static void krishh_samplexmlread(Args _args)
{
     XmlNode root;
     XmlNode book;
     XmlNodeList books;
     XmlNamespaceManager nsmgr;

     XmlDocument doc = new XmlDocument();
      int i=1;
      doc.Load(@"C:\Temp\book.xml");

      //Create an XmlNamespaceManager for resolving namespaces.
      nsmgr = new XmlNamespaceManager(doc.NameTable());
      nsmgr.AddNamespace("bk", "urn:samples");

      //Select the book node with the matching attribute value.


      root = doc.DocumentElement();

      books = root.selectNodes("descendant::book", nsmgr);
      for (i = 0; i < books.length(); i++)
      {
           book = books.item(i);
              info(book.selectSingleNode("bk:first-name").text());
              info(book.selectSingleNode("bk:last-name").text());


      }

}

//<?xml version="1.0"?>
//
//<!-- A fragment of a book store inventory database -->
//
//-<bookstore xmlns:bk="urn:samples">
//
//
//-<book bk:ISBN="1-861001-57-8" publicationdate="1997" genre="novel">
//
//<title>Pride And Prejudice</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>24.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861002-30-1" publicationdate="1992" genre="novel">
//
//<title>The Handmaid's Tale</title>
//
//
//-<author>
//
//<first-name>Margaret</first-name>
//
//<last-name>Atwood</last-name>
//
//</author>
//
//<price>29.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861001-57-6" publicationdate="1991" genre="novel">
//
//<title>Emma</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>


//-<book bk:ISBN="1-861001-45-3" publicationdate="1982" genre="novel">
//
//<title>Sense and Sensibility</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>
//
//</bookstore>

Comments

Popular posts from this blog

D365 : ENABLE AND DISABLE IN LIST PAGE

 here i have added 4 button in salesQuotationlistpage. now i need to enable/disable button according status. so i have Extensionof  of class SalesQuotationListPageInteraction and modify setButtonEnabled method by Chain of Command //list page button enable and diable in listpage interation class [ExtensionOf(classStr(SalesQuotationListPageInteraction))] final class SQTableinimathod_Extension {     protected void setButtonEnabled()     {                SalesQuotationTable SalesQuotationTable;         CustQuotationJour   CustQuotationJour;         CustQuotationConfirmJour  CustQuotationConfirmJour;               next setButtonEnabled();         SalesQuotationTable SalesQuotationTable1 = this.listPage().activeRecord(queryDataSourceStr(SalesQuotationListPage, SalesQuotationTable));         selec...

An error occurred during report data sets execution D365 For finance and operations

  Hi all, small tip. I faced this issue, when I extend the custom report in D365 for finance and operations. During development on onebox     Solution was simple, restart IIS services Restart Reporting Services. Happy Daxing.

CODE TO PDF IN AX 2012

static void Job1(Args _args) {         PurchPackingSlipController      ssrsController = new SrsReportRunController();         TradeDocumentReportContract     purchPackingSlipContract = new TradeDocumentReportContract();         SRSPrintDestinationSettings     printerSettings;         VendPackingSlipJour             VendPackingSlipJour;         Args                            args;         //select the latest record based on create date         while select VendPackingSlipJour             order by VendPackingSlipJour.createdDateTime DESC             where VendPackingSlipJour.PackingSlipId == 'LJ-01'         ...