RemoveNamespace(XMLDocIn : DotNet "System.Xml.XmlDocument";VAR XMLDocOut : DotNet "System.Xml.XmlDocument") // before this function your tag looks like this: <namespace:tagname>sample text</tagname> // after this function your tag looks like this: <tagname>sample text</tagname> // additionally all namespace references in the head are removed. XslTransform := XslTransform.XslTransform; XMLStyleSheet := XMLStyleSheet.XmlDocument; XMLStyleSheet.InnerXml( '<?xml version="1.0" encoding="UTF-8"?>' + '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' + '<xsl:output method="xml" encoding="UTF-8" />' + '<xsl:template match="/">' + '<xsl:copy>' + '<xsl:apply-templates />' + '</xsl:copy>' + '</xsl:template>' + '<xsl:template match="*">' + '<xsl:element name="{local-name()}">' + '<xsl:apply-templates select="@* | node()" />' + '</xsl:element>' + '</xsl:template>' + '<xsl:template match="@*">' + '<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>' + '</xsl:template>' + '<xsl:template match="text() | processing-instruction() | comment()">' + '<xsl:copy />' + '</xsl:template>' + '</xsl:stylesheet>' ); XslTransform.Load(XMLStyleSheet); writer := writer.StringWriter(); XslTransform.Transform(XMLDocIn, nullXsltArgumentList, writer); XMLDocOut := XMLDocOut.XmlDocument; // Inicializa el XML de salida XMLDocOut.InnerXml(writer.ToString());
RemoveNamespace(XMLResponseDoc, XMLResponseDoc);
XMLNodeList := XMLResponseDoc.GetElementsByTagName('Utilizador');
XMLNodeID := XMLNodeContainer.SelectSingleNode('Id'); XMLNodeUserName := XMLNodeContainer.SelectSingleNode('Username'); XMLNodeFullName := XMLNodeContainer.SelectSingleNode('FullName');
Answers
Nuno Silva
I get the same error.
If I put the code below, ir runs through the records returned by the web service
IF NOT ISNULL(XMLNodeID) THEN
MESSAGE('%1 - %2 - %3', FORMAT(XMLNodeID.Value), FORMAT(XMLNodeUserName.Value), FORMAT(XMLNodeFullName.Value));
Nuno Silva
And you need to remove the namespaces too.
You can use something like that
Local vars
Name DataType Subtype Length
XMLStyleSheet DotNet System.Xml.XmlDocument.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XslTransform DotNet System.Xml.Xsl.XslTransform.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
writer DotNet System.IO.StringWriter.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
nullXsltArgumentList DotNet System.Xml.Xsl.XsltArgumentList.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
And put this code:
before this line:
Thanks @ftornero
Nuno Silva