ReadOuterXml() public method

See XmlReader.ReadOuterXml.
public ReadOuterXml ( ) : string
return string
コード例 #1
0
 public void XPath1SchemeWithoutXmlnsTest() 
 {
     string xptr = "xpath1(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)";            
     XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsNsResource));
     XPointerReader xpr = new XPointerReader(reader, xptr);
     StringBuilder sb = new StringBuilder();
     while (xpr.Read()) {
         sb.Append(xpr.ReadOuterXml());
     }
     string expected = @"<pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name>";
     Assert.AreEqual(sb.ToString(), expected);
 }
コード例 #2
0
 public void UnknownSchemeTest3() 
 {           
     string xptr = "xmlns(foo=http://foo.com/schemas)foo:dummy(bar) element(/1/1/2)";                        
     XmlReader reader = new XmlTextReader("../../northwind.xml");            
     XPointerReader xpr = new XPointerReader(reader, xptr);
     string expected = @"<CompanyName> Alfreds Futterkiste</CompanyName>";
     while (xpr.Read()) 
     {
         Assert.AreEqual(xpr.ReadOuterXml(), expected);
         return;
     }            
     throw new InvalidOperationException("This means XPointer didn't work as expected.");
 }      
コード例 #3
0
 public void XSDDefnedIDTest() 
 {           
     string xptr = "element(id1389/1)";                        
     XmlReader reader = new XmlTextReader("../../pubsNS.xml");
     XPointerReader xpr = new XPointerReader(reader, xptr, true);
     string expected = @"<pub_name>Algodata Infosystems</pub_name>";
     while (xpr.Read()) 
     {
         Assert.AreEqual(xpr.ReadOuterXml(), expected);
         return;
     }            
     throw new InvalidOperationException("This means XPointer didn't work as expected.");
 }      
コード例 #4
0
 public void ElementSchemeTest2() 
 {           
     string xptr = "element(o10535/1)";                        
     XmlReader reader = new XmlTextReader("../../northwind.xml");            
     XPointerReader xpr = new XPointerReader(reader, xptr);
     string expected = @"<OrderDate> 6/13/95</OrderDate>";
     while (xpr.Read()) 
     {
         Assert.AreEqual(xpr.ReadOuterXml(), expected);
         return;
     }            
     throw new InvalidOperationException("This means XPointer didn't work as expected.");
 }
コード例 #5
0
 public void CompoundPointerTest() 
 {           
     string xptr = "xmlns(p=12345)xpath1(/no/such/node) xpointer(/and/such) element(/1/1/2) element(o10535/1)";                        
     XmlReader reader = new XmlTextReader("../../northwind.xml");            
     XPointerReader xpr = new XPointerReader(reader, xptr);
     string expected = @"<CompanyName> Alfreds Futterkiste</CompanyName>";
     while (xpr.Read()) 
     {
         Assert.AreEqual(xpr.ReadOuterXml(), expected);
         return;
     }            
     throw new InvalidOperationException("This means XPointer didn't work as expected.");
 }       
コード例 #6
0
 public void ShorthandTest() 
 {           
     string xptr = "o10535";                        
     XmlReader reader = new XmlTextReader("../../northwind.xml");            
     XPointerReader xpr = new XPointerReader(reader, xptr);
     string expected = @"<Item orderID=""o10535"">
         <OrderDate> 6/13/95</OrderDate>
         <ShipAddress> Mataderos  2312</ShipAddress>
     </Item>";
     while (xpr.Read()) 
     {
         Assert.AreEqual(xpr.ReadOuterXml(), expected);
         return;
     }            
     throw new InvalidOperationException("This means shorthand XPointer didn't work as expected.");
 }
コード例 #7
0
 public void ShorthandViaStreamTest() 
 {           
     string xptr = "o10535";                        
     FileInfo file = new FileInfo("../../northwind.xml");
     using (FileStream fs = file.OpenRead()) 
     {
         XPointerReader xpr = new XPointerReader(
             new XmlTextReader(file.FullName, fs), xptr);
         string expected = @"<Item orderID=""o10535"">
         <OrderDate> 6/13/95</OrderDate>
         <ShipAddress> Mataderos  2312</ShipAddress>
     </Item>";
         while (xpr.Read()) 
         {
             Assert.AreEqual(xpr.ReadOuterXml(), expected);
             return;
         }            
         throw new InvalidOperationException("This means shorthand XPointer didn't work as expected.");
     }
 }
コード例 #8
0
 public void NamespaceRedefinitionTest() 
 {
     string xptr = "xmlns(m=mvp-xml)xmlns(m=http://foo.com)xmlns(m=mvp-xml)xpointer(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)";            
     XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsNsResource));
     XPointerReader xpr = new XPointerReader(reader, xptr);
     StringBuilder sb = new StringBuilder();
     while (xpr.Read()) 
     {
         sb.Append(xpr.ReadOuterXml());
     }
     string expected = @"<pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name>";
     Assert.AreEqual(sb.ToString(), expected);
 }
コード例 #9
0
 public void SuperfluousXmlNsSchemeTest() 
 {
     string xptr = "xmlns(m=mvp-xml)xpointer(dsPubs/publishers[pub_id='1389']/pub_name)";            
     XmlReader reader = new XmlTextReader(Globals.GetResource(Globals.PubsResource));
     XPointerReader xpr = new XPointerReader(reader, xptr);
     StringBuilder sb = new StringBuilder();
     while (xpr.Read()) 
     {
         sb.Append(xpr.ReadOuterXml());
     }
     string expected = @"<pub_name>Algodata Infosystems</pub_name>";
     Assert.AreEqual(sb.ToString(), expected);
 }
コード例 #10
0
 public void UnknownSchemeTest2() 
 {           
     string xptr = "foo:dummy(bar) element(/1/1/2)";
     using (XmlReader reader = XmlReader.Create(
         "../../XPointer/northwind.xml", readerSettings))
     {
         XPointerReader xpr = new XPointerReader(reader, xptr);
         string expected = @"<CompanyName> Alfreds Futterkiste</CompanyName>";
         while (xpr.Read())
         {
             Assert.AreEqual(xpr.ReadOuterXml(), expected);
             return;
         }
         throw new InvalidOperationException("This means XPointer didn't work as expected.");
     }
 }      
コード例 #11
0
 public void ElementSchemeTest() 
 {           
     string xptr = "element(o10535)";            
     using (XmlReader reader = XmlReader.Create(
         "../../XPointer/northwind.xml", readerSettings))
     {
         XPointerReader xpr = new XPointerReader(reader, xptr);
         string expected = @"<Item orderID=""o10535""><OrderDate> 6/13/95</OrderDate><ShipAddress> Mataderos  2312</ShipAddress></Item>";
         while (xpr.Read())
         {
             Assert.AreEqual(xpr.ReadOuterXml(), expected);
             return;
         }
         throw new InvalidOperationException("This means XPointer didn't work as expected.");
     }
 }
コード例 #12
0
 public void XmlNsXPointerSchemeTest() 
 {
     string xptr = "xmlns(m=mvp-xml)xpointer(m:dsPubs/m:publishers[m:pub_id='1389']/m:pub_name)";
     using (XmlReader reader = XmlReader.Create(
         Globals.GetResource(Globals.PubsNsResource),
         readerSettings))
     {
         XPointerReader xpr = new XPointerReader(reader, xptr);
         StringBuilder sb = new StringBuilder();
         while (xpr.Read())
         {
             sb.Append(xpr.ReadOuterXml());
         }
         string expected = @"<pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name><pub_name xmlns=""mvp-xml"">Algodata Infosystems</pub_name>";
         Assert.AreEqual(sb.ToString(), expected);
     }
 }