Share via


XPathNavigator.ReplaceSelf Yöntem

Tanım

Geçerli düğümü belirtilen içerikle değiştirir.

Aşırı Yüklemeler

ReplaceSelf(XmlReader)

Geçerli düğümü belirtilen nesnenin XmlReader içeriğiyle değiştirir.

ReplaceSelf(XPathNavigator)

Geçerli düğümü belirtilen nesnenin XPathNavigator içeriğiyle değiştirir.

ReplaceSelf(String)

Geçerli düğümü belirtilen dizenin içeriğiyle değiştirir.

ReplaceSelf(XmlReader)

Source:
XPathNavigator.cs
Source:
XPathNavigator.cs
Source:
XPathNavigator.cs

Geçerli düğümü belirtilen nesnenin XmlReader içeriğiyle değiştirir.

public:
 virtual void ReplaceSelf(System::Xml::XmlReader ^ newNode);
public virtual void ReplaceSelf (System.Xml.XmlReader newNode);
abstract member ReplaceSelf : System.Xml.XmlReader -> unit
override this.ReplaceSelf : System.Xml.XmlReader -> unit
Public Overridable Sub ReplaceSelf (newNode As XmlReader)

Parametreler

newNode
XmlReader

XmlReader Yeni düğüm için XML verilerine konumlandırılmış bir nesne.

Özel durumlar

Nesne XmlReader bir hata durumunda veya kapalı.

XmlReader nesne parametresidirnull.

XPathNavigator öğesi, metin, işleme yönergesi veya açıklama düğümünde konumlandırılmaz.

düzenlemeyi XPathNavigator desteklemiyor.

Nesne parametresinin XmlReader XML içeriği iyi biçimlendirilmemiş.

Örnekler

Aşağıdaki örnekte price dosyadaki contosoBooks.xml öğesi yeni pages bir öğeyle değiştirilir.

XmlDocument^ document = gcnew XmlDocument();
document->Load("contosoBooks.xml");
XPathNavigator^ navigator = document->CreateNavigator();

navigator->MoveToChild("bookstore", "http://www.contoso.com/books");
navigator->MoveToChild("book", "http://www.contoso.com/books");
navigator->MoveToChild("price", "http://www.contoso.com/books");

XmlReader^ pages = XmlReader::Create(gcnew StringReader("<pages xmlns=\"http://www.contoso.com/books\">100</pages>"));

navigator->ReplaceSelf(pages);

Console::WriteLine("Position after delete: {0}", navigator->Name);
Console::WriteLine(navigator->OuterXml);
XmlDocument document = new XmlDocument();
document.Load("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();

navigator.MoveToChild("bookstore", "http://www.contoso.com/books");
navigator.MoveToChild("book", "http://www.contoso.com/books");
navigator.MoveToChild("price", "http://www.contoso.com/books");

XmlReader pages = XmlReader.Create(new StringReader("<pages xmlns=\"http://www.contoso.com/books\">100</pages>"));

navigator.ReplaceSelf(pages);

Console.WriteLine("Position after delete: {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XmlDocument = New XmlDocument()
document.Load("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

navigator.MoveToChild("bookstore", "http://www.contoso.com/books")
navigator.MoveToChild("book", "http://www.contoso.com/books")
navigator.MoveToChild("price", "http://www.contoso.com/books")

Dim pages As XmlReader = XmlReader.Create(New StringReader("<pages xmlns='http://www.contoso.com/books'>100</pages>"))

navigator.ReplaceSelf(pages)

Console.WriteLine("Position after delete: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)

Örnek, dosyayı giriş olarak alır contosoBooks.xml .

<?xml version="1.0" encoding="utf-8" ?>  
<bookstore xmlns="http://www.contoso.com/books">  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Açıklamalar

yöntemi XPathNavigator tamamlandığında yeni düğüme ReplaceSelf konumlandırılır ve döndürür true. XML XPathNavigator girişi olduğunda yöntemi tamamlandıktan ReplaceSelf sonra yeni düğüme konumlandırılmaz. Bu Empty durumdaXPathNavigator, değiştirilen düğümde bir sonraki eşdüzey düğüm yoksa ve döndürürsefalse, bir sonraki eşdüzey düğümde veya üst düğümde ReplaceSelf konumlandırılır.

  • ReplaceSelf yöntemi yalnızca öğesi, metin, işleme yönergesi veya açıklama düğümünde konumlandırıldığında XPathNavigator geçerlidir.

  • XML veri dizesi bir özel durum oluşturulmasından daha iyi biçimlendirilmemişse ve bu yöntemin sonucu geçerli düğümde çağrılmaya DeleteSelf eşdeğerse.

  • XML dizesi birden çok düğüm içeriyorsa, tüm düğümler eklenir ve XPathNavigator düğüm serisindeki ilk düğüme konumlandırılır.

  • ReplaceSelf yöntemi yöntemiyle DeleteSelf eşdeğer değildir.

Şunlara uygulanır

ReplaceSelf(XPathNavigator)

Source:
XPathNavigator.cs
Source:
XPathNavigator.cs
Source:
XPathNavigator.cs

Geçerli düğümü belirtilen nesnenin XPathNavigator içeriğiyle değiştirir.

public:
 virtual void ReplaceSelf(System::Xml::XPath::XPathNavigator ^ newNode);
public virtual void ReplaceSelf (System.Xml.XPath.XPathNavigator newNode);
abstract member ReplaceSelf : System.Xml.XPath.XPathNavigator -> unit
override this.ReplaceSelf : System.Xml.XPath.XPathNavigator -> unit
Public Overridable Sub ReplaceSelf (newNode As XPathNavigator)

Parametreler

newNode
XPathNavigator

XPathNavigator Yeni düğüme konumlandırılmış bir nesne.

Özel durumlar

XPathNavigator nesne parametresidirnull.

XPathNavigator öğesi, metin, işleme yönergesi veya açıklama düğümünde konumlandırılmaz.

düzenlemeyi XPathNavigator desteklemiyor.

Nesne parametresinin XPathNavigator XML içeriği iyi biçimlendirilmemiş.

Örnekler

Aşağıdaki örnekte price dosyadaki contosoBooks.xml öğesi yeni pages bir öğeyle değiştirilir.

XmlDocument^ document = gcnew XmlDocument();
document->Load("contosoBooks.xml");
XPathNavigator^ navigator = document->CreateNavigator();

navigator->MoveToChild("bookstore", "http://www.contoso.com/books");
navigator->MoveToChild("book", "http://www.contoso.com/books");
navigator->MoveToChild("price", "http://www.contoso.com/books");

XmlDocument^ childNodes = gcnew XmlDocument();
childNodes->Load(gcnew StringReader("<pages xmlns=\"http://www.contoso.com/books\">100</pages>"));
XPathNavigator^ childNodesNavigator = childNodes->CreateNavigator();

navigator->ReplaceSelf(childNodesNavigator);

Console::WriteLine("Position after delete: {0}", navigator->Name);
Console::WriteLine(navigator->OuterXml);
XmlDocument document = new XmlDocument();
document.Load("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();

navigator.MoveToChild("bookstore", "http://www.contoso.com/books");
navigator.MoveToChild("book", "http://www.contoso.com/books");
navigator.MoveToChild("price", "http://www.contoso.com/books");

XmlDocument childNodes = new XmlDocument();
childNodes.Load(new StringReader("<pages xmlns=\"http://www.contoso.com/books\">100</pages>"));
XPathNavigator childNodesNavigator = childNodes.CreateNavigator();

navigator.ReplaceSelf(childNodesNavigator);

Console.WriteLine("Position after delete: {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XmlDocument = New XmlDocument()
document.Load("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

navigator.MoveToChild("bookstore", "http://www.contoso.com/books")
navigator.MoveToChild("book", "http://www.contoso.com/books")
navigator.MoveToChild("price", "http://www.contoso.com/books")

Dim childNodes As XmlDocument = New XmlDocument()
childNodes.Load(New StringReader("<pages xmlns='http://www.contoso.com/books'>100</pages>"))
Dim childNodesNavigator As XPathNavigator = childNodes.CreateNavigator()

navigator.ReplaceSelf(childNodesNavigator)

Console.WriteLine("Position after delete: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)

Örnek, dosyayı giriş olarak alır contosoBooks.xml .

<?xml version="1.0" encoding="utf-8" ?>  
<bookstore xmlns="http://www.contoso.com/books">  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Açıklamalar

yöntemi XPathNavigator tamamlandığında yeni düğüme ReplaceSelf konumlandırılır ve döndürür true. XML XPathNavigator girişi olduğunda yöntemi tamamlandıktan ReplaceSelf sonra yeni düğüme konumlandırılmaz. Bu Empty durumdaXPathNavigator, değiştirilen düğümde bir sonraki eşdüzey düğüm yoksa ve döndürürsefalse, bir sonraki eşdüzey düğümde veya üst düğümde ReplaceSelf konumlandırılır.

  • ReplaceSelf yöntemi yalnızca öğesi, metin, işleme yönergesi veya açıklama düğümünde konumlandırıldığında XPathNavigator geçerlidir.

  • XML veri dizesi bir özel durum oluşturulmasından daha iyi biçimlendirilmemişse ve bu yöntemin sonucu geçerli düğümde çağrılmaya DeleteSelf eşdeğerse.

  • XML dizesi birden çok düğüm içeriyorsa, tüm düğümler eklenir ve XPathNavigator düğüm serisindeki ilk düğüme konumlandırılır.

  • ReplaceSelf yöntemi yöntemiyle DeleteSelf eşdeğer değildir.

Şunlara uygulanır

ReplaceSelf(String)

Source:
XPathNavigator.cs
Source:
XPathNavigator.cs
Source:
XPathNavigator.cs

Geçerli düğümü belirtilen dizenin içeriğiyle değiştirir.

public:
 virtual void ReplaceSelf(System::String ^ newNode);
public virtual void ReplaceSelf (string newNode);
abstract member ReplaceSelf : string -> unit
override this.ReplaceSelf : string -> unit
Public Overridable Sub ReplaceSelf (newNode As String)

Parametreler

newNode
String

Yeni düğüm için XML veri dizesi.

Özel durumlar

XML dizesi parametresi şeklindedir null.

XPathNavigator öğesi, metin, işleme yönergesi veya açıklama düğümünde konumlandırılmaz.

düzenlemeyi XPathNavigator desteklemiyor.

XML dizesi parametresi iyi biçimlendirilmemiş.

Örnekler

Aşağıdaki örnekte price dosyadaki contosoBooks.xml öğesi yeni pages bir öğeyle değiştirilir.

XmlDocument^ document = gcnew XmlDocument();
document->Load("contosoBooks.xml");
XPathNavigator^ navigator = document->CreateNavigator();

navigator->MoveToChild("bookstore", "http://www.contoso.com/books");
navigator->MoveToChild("book", "http://www.contoso.com/books");
navigator->MoveToChild("price", "http://www.contoso.com/books");

navigator->ReplaceSelf("<pages>100</pages>");

Console::WriteLine("Position after delete: {0}", navigator->Name);
Console::WriteLine(navigator->OuterXml);
XmlDocument document = new XmlDocument();
document.Load("contosoBooks.xml");
XPathNavigator navigator = document.CreateNavigator();

navigator.MoveToChild("bookstore", "http://www.contoso.com/books");
navigator.MoveToChild("book", "http://www.contoso.com/books");
navigator.MoveToChild("price", "http://www.contoso.com/books");

navigator.ReplaceSelf("<pages>100</pages>");

Console.WriteLine("Position after delete: {0}", navigator.Name);
Console.WriteLine(navigator.OuterXml);
Dim document As XmlDocument = New XmlDocument()
document.Load("contosoBooks.xml")
Dim navigator As XPathNavigator = document.CreateNavigator()

navigator.MoveToChild("bookstore", "http://www.contoso.com/books")
navigator.MoveToChild("book", "http://www.contoso.com/books")
navigator.MoveToChild("price", "http://www.contoso.com/books")

navigator.ReplaceSelf("<pages>100</pages>")

Console.WriteLine("Position after delete: {0}", navigator.Name)
Console.WriteLine(navigator.OuterXml)

Örnek, dosyayı giriş olarak alır contosoBooks.xml .

<?xml version="1.0" encoding="utf-8" ?>  
<bookstore xmlns="http://www.contoso.com/books">  
    <book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">  
        <title>The Autobiography of Benjamin Franklin</title>  
        <author>  
            <first-name>Benjamin</first-name>  
            <last-name>Franklin</last-name>  
        </author>  
        <price>8.99</price>  
    </book>  
    <book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">  
        <title>The Confidence Man</title>  
        <author>  
            <first-name>Herman</first-name>  
            <last-name>Melville</last-name>  
        </author>  
        <price>11.99</price>  
    </book>  
    <book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">  
        <title>The Gorgias</title>  
        <author>  
            <name>Plato</name>  
        </author>  
        <price>9.99</price>  
    </book>  
</bookstore>  

Açıklamalar

yöntemi XPathNavigator tamamlandığında yeni düğüme ReplaceSelf konumlandırılır ve döndürür true. XML XPathNavigator girişi olduğunda yöntemi tamamlandıktan ReplaceSelf sonra yeni düğüme konumlandırılmaz. Bu Empty durumdaXPathNavigator, değiştirilen düğümde bir sonraki eşdüzey düğüm yoksa ve döndürürsefalse, bir sonraki eşdüzey düğümde veya üst düğümde ReplaceSelf konumlandırılır.

  • ReplaceSelf yöntemi yalnızca öğesi, metin, işleme yönergesi veya açıklama düğümünde konumlandırıldığında XPathNavigator geçerlidir.

  • XML veri dizesi bir özel durum oluşturulmasından daha iyi biçimlendirilmemişse ve bu yöntemin sonucu geçerli düğümde çağrılmaya DeleteSelf eşdeğerse.

  • XML dizesi birden çok düğüm içeriyorsa, tüm düğümler eklenir ve XPathNavigator düğüm serisindeki ilk düğüme konumlandırılır.

  • ReplaceSelf yöntemi yöntemiyle DeleteSelf eşdeğer değildir.

Şunlara uygulanır