XPathNavigator.InsertBefore 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 선택된 노드 앞에 새 형제 노드를 만듭니다.
오버로드
| Name | Description |
|---|---|
| InsertBefore() |
XmlWriter 현재 선택된 노드 앞에 새 형제 노드를 만드는 데 사용되는 개체를 반환합니다. |
| InsertBefore(String) |
지정된 XML 문자열을 사용하여 현재 선택된 노드 앞에 새 형제 노드를 만듭니다. |
| InsertBefore(XmlReader) |
지정된 개체의 XML 내용을 사용하여 현재 선택된 노드 앞에 새 형제 노드를 XmlReader 만듭니다. |
| InsertBefore(XPathNavigator) |
지정된 노드를 사용하여 현재 선택된 노드 앞에 새 형제 노드를 XPathNavigator 만듭니다. |
InsertBefore()
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
XmlWriter 현재 선택된 노드 앞에 새 형제 노드를 만드는 데 사용되는 개체를 반환합니다.
public:
virtual System::Xml::XmlWriter ^ InsertBefore();
public virtual System.Xml.XmlWriter InsertBefore();
abstract member InsertBefore : unit -> System.Xml.XmlWriter
override this.InsertBefore : unit -> System.Xml.XmlWriter
Public Overridable Function InsertBefore () As XmlWriter
반품
XmlWriter 현재 선택된 노드 앞에 새 형제 노드를 만드는 데 사용되는 개체입니다.
예외
위치 XPathNavigator 는 현재 노드 앞에 새 형제 노드를 삽입할 수 없습니다.
편집을 XPathNavigator 지원하지 않습니다.
예제
다음 예제에서는 메서드에서 반환된 개체를 사용하여 파일에서 첫 번째 pages 요소의 자식 요소 앞에 새 price 요소를 book 삽입합니다contosoBooks.xml.XmlWriterInsertBefore
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.InsertBefore();
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.InsertBefore()
pages.WriteElementString("pages", "100")
pages.Close()
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
이 예제에서는 파일을 입력으로 사용합니다 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>
설명
다음은 메서드를 사용할 때 고려해야 할 중요한 참고 사항입니다 InsertBefore .
이 InsertBefore 메서드는 요소, 텍스트, 처리 명령 또는 주석 노드에 배치된 경우에만 XPathNavigator 유효합니다.
메서드는 InsertBefore .의 XPathNavigator위치에 영향을 주지 않습니다.
적용 대상
InsertBefore(String)
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
지정된 XML 문자열을 사용하여 현재 선택된 노드 앞에 새 형제 노드를 만듭니다.
public:
virtual void InsertBefore(System::String ^ newSibling);
public virtual void InsertBefore(string newSibling);
abstract member InsertBefore : string -> unit
override this.InsertBefore : string -> unit
Public Overridable Sub InsertBefore (newSibling As String)
매개 변수
- newSibling
- String
새 형제 노드의 XML 데이터 문자열입니다.
예외
XML 문자열 매개 변수는 .입니다 null.
위치 XPathNavigator 는 현재 노드 앞에 새 형제 노드를 삽입할 수 없습니다.
편집을 XPathNavigator 지원하지 않습니다.
XML 문자열 매개 변수의 형식이 잘못되었습니다.
예제
다음 예제에서는 pages 파일의 첫 번째 price 요소의 book 자식 요소 앞에 새 contosoBooks.xml 요소가 삽입됩니다.
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.InsertBefore("<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.InsertBefore("<pages>100</pages>")
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
이 예제에서는 파일을 입력으로 사용합니다 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>
설명
새 요소 노드를 만들려면 XML 문자열 매개 변수에 모든 XML 구문을 포함합니다. 새 book 노드의 문자열은 .입니다 InsertBefore("<book/>"). 현재 노드의 텍스트 노드 앞에 "book" 텍스트를 삽입하기 위한 문자열입니다 InsertBefore("book"). XML 문자열에 여러 노드가 포함된 경우 모든 노드가 추가됩니다.
다음은 메서드를 사용할 때 고려해야 할 중요한 참고 사항입니다 InsertBefore .
이 InsertBefore 메서드는 요소, 텍스트, 처리 명령 또는 주석 노드에 배치된 경우에만 XPathNavigator 유효합니다.
메서드는 InsertBefore .의 XPathNavigator위치에 영향을 주지 않습니다.
적용 대상
InsertBefore(XmlReader)
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
지정된 개체의 XML 내용을 사용하여 현재 선택된 노드 앞에 새 형제 노드를 XmlReader 만듭니다.
public:
virtual void InsertBefore(System::Xml::XmlReader ^ newSibling);
public virtual void InsertBefore(System.Xml.XmlReader newSibling);
abstract member InsertBefore : System.Xml.XmlReader -> unit
override this.InsertBefore : System.Xml.XmlReader -> unit
Public Overridable Sub InsertBefore (newSibling As XmlReader)
매개 변수
예외
XmlReader 개체가 오류 상태이거나 닫혀 있습니다.
개체 매개 변수는 XmlReader .입니다 null.
위치 XPathNavigator 는 현재 노드 앞에 새 형제 노드를 삽입할 수 없습니다.
편집을 XPathNavigator 지원하지 않습니다.
개체 매개 변수의 XML 내용이 XmlReader 잘 구성되지 않았습니다.
예제
다음 예제에서는 지정된 개체를 사용하여 pages 파일에서 price 첫 번째 book 요소의 자식 요소 앞에 새 contosoBooks.xml 요소를 XmlReader 삽입합니다.
http://www.contoso.com/books 새 형제 요소가 XML 문서와 동일한 네임스페이스를 사용하여 삽입되도록 네임스페이스를 지정합니다.
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.InsertBefore(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.InsertBefore(pages)
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
이 예제에서는 파일을 입력으로 사용합니다 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>
설명
다음은 메서드를 사용할 때 고려해야 할 중요한 참고 사항입니다 InsertBefore .
개체가 XmlReader XML 노드 시퀀스 위에 배치되면 시퀀스의 모든 노드가 추가됩니다.
이 InsertBefore 메서드는 요소, 텍스트, 처리 명령 또는 주석 노드에 배치된 경우에만 XPathNavigator 유효합니다.
메서드는 InsertBefore .의 XPathNavigator위치에 영향을 주지 않습니다.
적용 대상
InsertBefore(XPathNavigator)
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
- Source:
- XPathNavigator.cs
지정된 노드를 사용하여 현재 선택된 노드 앞에 새 형제 노드를 XPathNavigator 만듭니다.
public:
virtual void InsertBefore(System::Xml::XPath::XPathNavigator ^ newSibling);
public virtual void InsertBefore(System.Xml.XPath.XPathNavigator newSibling);
abstract member InsertBefore : System.Xml.XPath.XPathNavigator -> unit
override this.InsertBefore : System.Xml.XPath.XPathNavigator -> unit
Public Overridable Sub InsertBefore (newSibling As XPathNavigator)
매개 변수
- newSibling
- XPathNavigator
XPathNavigator 새 형제 노드로 추가할 노드에 배치된 개체입니다.
예외
개체 매개 변수는 XPathNavigator .입니다 null.
위치 XPathNavigator 는 현재 노드 앞에 새 형제 노드를 삽입할 수 없습니다.
편집을 XPathNavigator 지원하지 않습니다.
예제
다음 예제에서는 지정된 개체에 포함된 pages 노드를 price 사용하여 파일에서 첫 번째 book 요소의 자식 요소 앞에 새 contosoBooks.xml 요소를 XPathNavigator 삽입합니다.
http://www.contoso.com/books 새 형제 요소가 XML 문서와 동일한 네임스페이스를 사용하여 삽입되도록 네임스페이스를 지정합니다.
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.InsertBefore(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.InsertBefore(childNodesNavigator)
navigator.MoveToParent()
Console.WriteLine(navigator.OuterXml)
이 예제에서는 파일을 입력으로 사용합니다 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>
설명
다음은 메서드를 사용할 때 고려해야 할 중요한 참고 사항입니다 InsertBefore .
개체가 XPathNavigator XML 노드 시퀀스 위에 배치되면 시퀀스의 모든 노드가 추가됩니다.
이 InsertBefore 메서드는 요소, 텍스트, 처리 명령 또는 주석 노드에 배치된 경우에만 XPathNavigator 유효합니다.
메서드는 InsertBefore .의 XPathNavigator위치에 영향을 주지 않습니다.