Options

selectsinglenode (dotnet variable) unable to return a value

matthewtaingmatthewtaing Member Posts: 52
edited 2013-05-16 in NAV Three Tier
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
<?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

Comments

  • Options
    ta5ta5 Member Posts: 1,164
    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
    Thomas
  • Options
    matthewtaingmatthewtaing Member Posts: 52
    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.

    Thanks
  • Options
    wakestarwakestar Member Posts: 207
    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 again
Sign In or Register to comment.