web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Read Xml file and get the Action attribut.

(0) ShareShare
ReportReport
Posted on by 85

Hi,

I try to read an xml-file and have problem to get the action attirbut:

The xml looks like this:

 

<?xml version="1.0" encoding="iso-8859-1"?>
<Product action="create" xmlns="http://www.test/formatimport">
  <TitleCode>TTTT</TitleCode>
  <Date>2012-04-26</Date>
  <Edition>SI</Edition>
  <SectionSizes>20</SectionSizes>
  <Page>
    <PageNumber>1</PageNumber>
    <Colours>c m y k</Colours>
    <Name>Etusivu</Name>
    <Type>Etusivu</Type>
  </Page>..........................


 My Code is:

 

    XMLDocument     xmlDoc;
    XMLNode              rootNode;
    XMLNode              pageNodeRecord;

    XMLNodeList     salesLines, pageNodeList;
    XMLParseError   xmlError; 

    rootNode = xmlDoc.documentElement();
    // Get the action attribut???? 

    // Get information from nodes. 
    titlecode = rootNode.selectSingleNode("//TitleCode").text();
    dat          = rootNode.selectSingleNode("//Date").text();

My problem is that I cant get the attribut  action="create" .

I tried different methods under rootNode and didnt find a way to get it.

Does somebody know how to do this??

 Thanks for help.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,876 Most Valuable Professional on at

    The easiest option is to simply call rootNode.getAttribute('action').

    Another option is to benefit from the fact that selectSingleNode() accepts XPath - you can get the value by calling rootNode.selectSingleNode('@action').value() or even xmlDoc.selectSingleNode('Product/@action).value(). XPath is really helpful in more complex scenarios.

    You have even more ways, e.g. to use rootNode.attributes().getNamedItem('action').

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans