Hello !
I can't get this code to work. I want to use xpath with selectSingleNode but because the xml has name space defined (xmlns ='http://www.test/formatimport' ) the selectSingleNode returns null. If I remove the namespace from xml the code works fine. Which is the right code?
XmlDocument xmlDocument; XmlNode xmlInformationNode; XmlNode xmlTransUnit; XmlNode xmlTarget; XmlNode xmlRoot; XmlNamespaceManager XmlNamespaceManager; str nodename; str xml; xml = "<?xml version='1.0' encoding='iso-8859-1'?>" + "<Product action='create' xmlns ='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>" + "</Product>"; xmlDocument = new xmlDocument(); xmlDocument.loadXml(xml); XmlNamespaceManager = new XmlNamespaceManager(xmlDocument.nameTable()); xmlRoot = xmlDocument.documentElement(); //This do not work when I have namespace defined in xml header xmlTarget = xmlRoot.selectSingleNode("//TitleCode", XmlNamespaceManager); xmlTarget = xmlRoot.selectSingleNode("//TitleCode"); //This works fine when the xml doesn't have xmlns defined //xmlTarget = xmlRoot.selectSingleNode("//TitleCode"); nodename = xmlTarget.name();
*This post is locked for comments