selectsinglenode (dotnet variable) unable to return a value

matthewtaing
Member Posts: 52
Hi,
In the midst of upgrading functions which involves automations to dotnet variables. Can't seem to get the selectsinglenode function to work. Below is the xml file that I have and the code to read it.
XML file
Code to read FunctionName from a MSMQ message in xml format.
Appreciate all the help that I can get. Thanks
In the midst of upgrading functions which involves automations to dotnet variables. Can't seem to get the selectsinglenode function to work. Below is the xml file that I have and the code to read it.
XML file
<?xml version="1.0"?> <NavisionObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www-Navision-com:NavisionObject.xml"> <UserName/> <CompanyName/> <FunctionName>GetCompanyName</FunctionName> <ParameterList/> <Result/> </NavisionObject>
Code to read FunctionName from a MSMQ message in xml format.
Q := Q.MessageQueue('.\private$\temp'); Q.Formatter := QActiveXFormatter.ActiveXMessageFormatter; IF TryPeek THEN BEGIN QMsg := Q.Peek(TS.TimeSpan(0,0,1)); END ELSE BEGIN CLEAR(ReceiveMSMQ); ReceiveMSMQ.SetTryPeek; IF ReceiveMSMQ.RUN THEN REPEAT QMsg := Q.Receive(TS.TimeSpan(0,0,10)); InStream2 := QMsg.BodyStream; REPEAT InStream2.READTEXT(XMLChar); XMLText := XMLText + XMLChar; UNTIL InStream2.EOS; XMLDoc2 := XMLDoc2.XmlDocument; XMLDoc2.LoadXml(XMLText); XMLNode2 := XMLDoc2.SelectSingleNode('/NavisionObject/FunctionName'); IF NOT ISNULL(XMLNode2) THEN MESSAGE('Success') ELSE MESSAGE('Failed'); CLEAR(ReceiveMSMQ); ReceiveMSMQ.SetTryPeek; UNTIL NOT ReceiveMSMQ.RUN ; END; NameDataType Subtype Length XMLNode2 DotNet System.Xml.XmlNode.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLDoc2 DotNet System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Appreciate all the help that I can get. Thanks
0
Comments
-
Just my 2 cents: Try to load the XML in a good XML Editor (for example xmlSpy) and enter the xpath expression there.
Hope this helps
Thomas0 -
tested with oxygen xml and the xpath expression works fine. The xml file used to work with automation's selectsinglenode but now that I've changed it to dotnet variable, I suspect that I might be doing something wrong or missing some syntax.
Thanks0 -
the problem is here:
xmlns="urn:www-Navision-com:NavisionObject.xml"
this namespace doesn't have a prefix like the first two namespaces...
remove this namespace and try again0
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
- 320 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