Exemplo n.º 1
0
        public void XmlReaderNames()
        {
            string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";

            XPathNavigator nav    = new XPathDocument(new StringReader(xml)).CreateNavigator();
            XmlReader      reader = new XPathNavigatorReader(nav);

            reader.MoveToContent();
            Assert.AreEqual("customer", reader.Name);

            reader.MoveToFirstAttribute();
            Assert.AreEqual("id", reader.Name);

            reader.MoveToNextAttribute();
            Assert.AreEqual("pp:id", reader.Name);

            // Namespace order is not guaranteed.
            reader.MoveToNextAttribute();
            Assert.IsTrue(reader.Name == "xmlns:pp" || reader.Name == "xmlns");
            reader.MoveToNextAttribute();
            Assert.IsTrue(reader.Name == "xmlns:pp" || reader.Name == "xmlns");

            reader.MoveToElement();
            reader.Read();

            Assert.AreEqual("pp:order", reader.Name);
        }
Exemplo n.º 2
0
		public void XmlReaderNames()
		{
			string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";

			XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();
			XmlReader reader = new XPathNavigatorReader(nav);

			reader.MoveToContent();
			Assert.AreEqual("customer", reader.Name);
			
			reader.MoveToFirstAttribute();
			Assert.AreEqual("id", reader.Name);

			reader.MoveToNextAttribute();
			Assert.AreEqual("pp:id", reader.Name);
		
			// Namespace order is not guaranteed.
            reader.MoveToNextAttribute();
			Assert.IsTrue( reader.Name == "xmlns:pp" || reader.Name == "xmlns" );
			reader.MoveToNextAttribute();
			Assert.IsTrue( reader.Name == "xmlns:pp" || reader.Name == "xmlns" );

			reader.MoveToElement();
			reader.Read();

			Assert.AreEqual("pp:order", reader.Name);
		}