XPathNavigator.InsertAfter Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturur.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| InsertAfter(XPathNavigator) |
Belirtilen nesnedeki XPathNavigator düğümleri kullanarak seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturur. |
| InsertAfter(XmlReader) |
Belirtilen nesnenin XML içeriğini XmlReader kullanarak seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturur. |
| InsertAfter() |
Seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturmak için kullanılan nesneyi XmlWriter döndürür. |
| InsertAfter(String) |
Belirtilen XML dizesini kullanarak seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturur. |
InsertAfter(XPathNavigator)
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
Belirtilen nesnedeki XPathNavigator düğümleri kullanarak seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturur.
public:
virtual void InsertAfter(System::Xml::XPath::XPathNavigator ^ newSibling);
public virtual void InsertAfter(System.Xml.XPath.XPathNavigator newSibling);
abstract member InsertAfter : System.Xml.XPath.XPathNavigator -> unit
override this.InsertAfter : System.Xml.XPath.XPathNavigator -> unit
Public Overridable Sub InsertAfter (newSibling As XPathNavigator)
Parametreler
- newSibling
- XPathNavigator
XPathNavigator Yeni eşdüzey düğüm olarak eklenecek düğümde konumlandırılan nesne.
Özel durumlar
XPathNavigator nesne parametresidirnull.
konumu XPathNavigator , geçerli düğümden sonra yeni bir eşdüzey düğümün eklenmesine izin vermez.
XPathNavigator düzenlemeyi desteklemiyor.
Örnekler
Aşağıdaki örnekte, belirtilen nesnede pages bulunan price düğüm kullanılarak dosyadaki book ilk contosoBooks.xml öğenin alt öğesinden sonra yeni XPathNavigator bir öğe eklenir. Ad http://www.contoso.com/books alanı, yeni eşdüzey öğenin XML belgesiyle aynı ad alanı kullanılarak eklenmesi için belirtilir.
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.InsertAfter(childNodesNavigator);
navigator.MoveToParent();
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.InsertAfter(childNodesNavigator)
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
Örnek, contosoBooks.xml dosyasını giriş olarak alır.
<?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 kullanırken dikkate alınması gereken önemli notlar aşağıdadır InsertAfter .
XmlReader Nesne bir XML düğümleri dizisinin üzerine yerleştirilirse, dizideki tüm düğümler eklenir.
InsertAfter yöntemi yalnızca öğesinde, metinde, işleme yönergesinde veya açıklama düğümünde konumlandırıldığında XPathNavigator geçerlidir.
yöntemi, InsertAfter konumunu XPathNavigatoretkilemez.
Şunlara uygulanır
InsertAfter(XmlReader)
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
Belirtilen nesnenin XML içeriğini XmlReader kullanarak seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturur.
public:
virtual void InsertAfter(System::Xml::XmlReader ^ newSibling);
public virtual void InsertAfter(System.Xml.XmlReader newSibling);
abstract member InsertAfter : System.Xml.XmlReader -> unit
override this.InsertAfter : System.Xml.XmlReader -> unit
Public Overridable Sub InsertAfter (newSibling As XmlReader)
Parametreler
Özel durumlar
XmlReader Nesne bir hata durumunda veya kapatıldı.
XmlReader nesne parametresidirnull.
konumu XPathNavigator , geçerli düğümden sonra yeni bir eşdüzey düğümün eklenmesine izin vermez.
XPathNavigator düzenlemeyi desteklemiyor.
Nesne parametresinin XmlReader XML içeriği iyi biçimlendirilmemiş.
Örnekler
Aşağıdaki örnekte, belirtilen nesne kullanılarak pages dosyadaki pricebook ilk contosoBooks.xml öğenin alt öğesinden sonra yeni XmlReader bir öğe eklenir. Ad http://www.contoso.com/books alanı, yeni eşdüzey öğenin XML belgesiyle aynı ad alanı kullanılarak eklenmesi için belirtilir.
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.InsertAfter(pages);
navigator.MoveToParent();
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.InsertAfter(pages)
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
Örnek, contosoBooks.xml dosyasını giriş olarak alır.
<?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 kullanırken dikkate alınması gereken önemli notlar aşağıdadır InsertAfter .
XmlReader Nesne bir XML düğümleri dizisinin üzerine yerleştirilirse, dizideki tüm düğümler eklenir.
InsertAfter yöntemi yalnızca öğesinde, metinde, işleme yönergesinde veya açıklama düğümünde konumlandırıldığında XPathNavigator geçerlidir.
yöntemi, InsertAfter konumunu XPathNavigatoretkilemez.
Şunlara uygulanır
InsertAfter()
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
Seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturmak için kullanılan nesneyi XmlWriter döndürür.
public:
virtual System::Xml::XmlWriter ^ InsertAfter();
public virtual System.Xml.XmlWriter InsertAfter();
abstract member InsertAfter : unit -> System.Xml.XmlWriter
override this.InsertAfter : unit -> System.Xml.XmlWriter
Public Overridable Function InsertAfter () As XmlWriter
Döndürülenler
Seçili XmlWriter durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturmak için kullanılan nesne.
Özel durumlar
konumu XPathNavigator , geçerli düğümden sonra yeni bir eşdüzey düğümün eklenmesine izin vermez.
XPathNavigator düzenlemeyi desteklemiyor.
Örnekler
Aşağıdaki örnekte, yöntemi tarafından pages döndürülen nesnesi kullanılarak price dosyadaki book ilk contosoBooks.xml öğenin alt öğesinden sonra XmlWriter yeni InsertAfter bir öğe eklenir.
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");
XmlWriter pages = navigator.InsertAfter();
pages.WriteElementString("pages", "100");
pages.Close();
navigator.MoveToParent();
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 XmlWriter = navigator.InsertAfter()
pages.WriteElementString("pages", "100")
pages.Close()
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
Örnek, contosoBooks.xml dosyasını giriş olarak alır.
<?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 kullanırken dikkate alınması gereken önemli notlar aşağıdadır InsertAfter .
Nesnenin yöntemi Close çağrılana XmlWriter kadar yeni eşdüzey düğüm eklenmez.
InsertAfter yöntemi yalnızca öğesinde, metinde, işleme yönergesinde veya açıklama düğümünde konumlandırıldığında XPathNavigator geçerlidir.
yöntemi, InsertAfter konumunu XPathNavigatoretkilemez.
Şunlara uygulanır
InsertAfter(String)
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
- Kaynak:
- XPathNavigator.cs
Belirtilen XML dizesini kullanarak seçili durumdaki düğümden sonra yeni bir eşdüzey düğüm oluşturur.
public:
virtual void InsertAfter(System::String ^ newSibling);
public virtual void InsertAfter(string newSibling);
abstract member InsertAfter : string -> unit
override this.InsertAfter : string -> unit
Public Overridable Sub InsertAfter (newSibling As String)
Parametreler
- newSibling
- String
Yeni eşdüzey düğüm için XML veri dizesi.
Özel durumlar
XML dizesi parametresidir null.
konumu XPathNavigator , geçerli düğümden sonra yeni bir eşdüzey düğümün eklenmesine izin vermez.
XPathNavigator düzenlemeyi desteklemiyor.
XML dizesi parametresi iyi biçimlendirilmemiş.
Örnekler
Aşağıdaki örnekte, dosyadaki ilk pages öğenin alt öğesinden sonra price yeni book bir öğe contosoBooks.xml eklenir.
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.InsertAfter("<pages>100</pages>");
navigator.MoveToParent();
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.InsertAfter("<pages>100</pages>")
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
Örnek, contosoBooks.xml dosyasını giriş olarak alır.
<?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
Yeni bir öğe düğümü oluşturmak için, XML dizesi parametresine tüm XML söz dizimini ekleyin. Yeni book düğümün dizesi şeklindedir InsertAfter("<book/>"). Geçerli düğümün metin düğümünden sonra "book" metnini ekleme dizesidir InsertAfter("book"). XML dizesi birden çok düğüm içeriyorsa, tüm düğümler eklenir.
Yöntemi kullanırken dikkate alınması gereken önemli notlar aşağıdadır InsertAfter .
InsertAfter yöntemi yalnızca öğesinde, metinde, işleme yönergesinde veya açıklama düğümünde konumlandırıldığında XPathNavigator geçerlidir.
yöntemi, InsertAfter konumunu XPathNavigatoretkilemez.