diff --git a/.openpublishing.redirection.json b/.openpublishing.redirection.json index afc418c13c753..9fb80a57fb11e 100644 --- a/.openpublishing.redirection.json +++ b/.openpublishing.redirection.json @@ -1265,6 +1265,26 @@ "redirect_url": "/dotnet/standard/linq/build-linq-xml-examples", "redirect_document_id": true }, + { + "source_path": "docs/csharp/programming-guide/concepts/linq/how-to-catch-parsing-errors.md", + "redirect_url": "/dotnet/standard/linq/catch-parsing-errors", + "redirect_document_id": true + }, + { + "source_path": "docs/csharp/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md", + "redirect_url": "/dotnet/standard/linq/create-tree-xmlreader", + "redirect_document_id": true + }, + { + "source_path": "docs/csharp/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md", + "redirect_url": "/dotnet/standard/linq/load-xml-file", + "redirect_document_id": true + }, + { + "source_path": "docs/csharp/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml1.md", + "redirect_url": "/dotnet/standard/linq/preserve-white-space-loading-parsing-xml", + "redirect_document_id": true + }, { "source_path": "docs/csharp/programming-guide/concepts/linq/creating-xml-trees-linq-to-xml-2.md", "redirect_url": "/dotnet/standard/linq/create-xml-trees", @@ -4280,6 +4300,26 @@ "source_path": "docs/visual-basic/programming-guide/concepts/linq/how-to-build-linq-to-xml-examples.md", "redirect_url": "/dotnet/standard/linq/build-linq-xml-examples" }, + { + "source_path": "docs/visual-basic/programming-guide/concepts/linq/how-to-catch-parsing-errors.md", + "redirect_url": "/dotnet/standard/linq/catch-parsing-errors", + "redirect_document_id": false + }, + { + "source_path": "docs/visual-basic/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md", + "redirect_url": "/dotnet/standard/linq/create-tree-xmlreader", + "redirect_document_id": false + }, + { + "source_path": "docs/visual-basic/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md", + "redirect_url": "/dotnet/standard/linq/load-xml-file", + "redirect_document_id": false + }, + { + "source_path": "docs/visual-basic/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml.md", + "redirect_url": "/dotnet/standard/linq/preserve-white-space-loading-parsing-xml", + "redirect_document_id": false + }, { "source_path": "docs/visual-basic/programming-guide/concepts/linq/functional-construction-linq-to-xml.md", "redirect_url": "/dotnet/standard/linq/functional-construction" diff --git a/docs/csharp/programming-guide/concepts/linq/how-to-catch-parsing-errors.md b/docs/csharp/programming-guide/concepts/linq/how-to-catch-parsing-errors.md deleted file mode 100644 index 363f5be0cd6e0..0000000000000 --- a/docs/csharp/programming-guide/concepts/linq/how-to-catch-parsing-errors.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: "How to catch parsing errors (C#)" -ms.date: 07/20/2015 -ms.assetid: bfb612d4-5605-48ef-8c93-915cf9d5dcfb ---- -# How to catch parsing errors (C#) -This topic shows how to detect badly formed or invalid XML. - - [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)] is implemented using . If badly formed or invalid XML is passed to [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)], the underlying class will throw an exception. The various methods that parse XML, such as , do not catch the exception; the exception can then be caught by your application. - -## Example - The following code tries to parse invalid XML: - -```csharp -try { - XElement contacts = XElement.Parse( - @" - - Jim Wilson - - "); - - Console.WriteLine(contacts); -} -catch (System.Xml.XmlException e) -{ - Console.WriteLine(e.Message); -} -``` - - When you run this code, it throws the following exception: - -```console -The 'Contacts' start tag on line 1 does not match the end tag of 'Contcts'. Line 5, position 13. -``` - - For information about the exceptions that you can expect the , , , and methods to throw, see the documentation. - \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md b/docs/csharp/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md deleted file mode 100644 index 1df3244b7402b..0000000000000 --- a/docs/csharp/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: "How to create a tree from an XmlReader (C#)" -ms.date: 07/20/2015 -ms.assetid: 60951c9c-7087-406c-b5bb-c60e58609b21 ---- -# How to create a tree from an XmlReader (C#) -This topic shows how to create an XML tree directly from an . To create an from an , you must position the on an element node. The will skip comments and processing instructions, but if the is positioned on a text node, an error will be thrown. To avoid such errors, always position the on an element before you create an XML tree from the . - -## Example - This example uses the following XML document: [Sample XML File: Books (LINQ to XML)](./sample-xml-file-books-linq-to-xml.md). - - The following code creates an `T:System.Xml.XmlReader` object, and then reads nodes until it finds the first element node. It then loads the object. - -```csharp -XmlReader r = XmlReader.Create("books.xml"); -while (r.NodeType != XmlNodeType.Element) - r.Read(); -XElement e = XElement.Load(r); -Console.WriteLine(e); -``` - - This example produces the following output: - -```xml - - - Garghentini, Davide - XML Developer's Guide - Computer - 44.95 - 2000-10-01 - An in-depth look at creating applications - with XML. - - - Garcia, Debra - Midnight Rain - Fantasy - 5.95 - 2000-12-16 - A former architect battles corporate zombies, - an evil sorceress, and her own childhood to become queen - of the world. - - -``` - -## See also - -- [Parsing XML (C#)](how-to-parse-a-string.md) diff --git a/docs/csharp/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md b/docs/csharp/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md deleted file mode 100644 index d4641e6d992e6..0000000000000 --- a/docs/csharp/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: "How to load XML from a file (C#)" -ms.date: 07/20/2015 -ms.assetid: 3ed38487-8028-4209-9872-c8dce0ed4dfe ---- -# How to load XML from a file (C#) -This topic shows how to load XML from a URI by using the method. - -## Example - The following example shows how to load an XML document from a file. The following example loads books.xml and outputs the XML tree to the console. - - This example uses the following XML document: [Sample XML File: Books (LINQ to XML)](./sample-xml-file-books-linq-to-xml.md). - -```csharp -XElement booksFromFile = XElement.Load(@"books.xml"); -Console.WriteLine(booksFromFile); -``` - - This code produces the following output: - -```xml - - - Garghentini, Davide - XML Developer's Guide - Computer - 44.95 - 2000-10-01 - An in-depth look at creating applications - with XML. - - - Garcia, Debra - Midnight Rain - Fantasy - 5.95 - 2000-12-16 - A former architect battles corporate zombies, - an evil sorceress, and her own childhood to become queen - of the world. - - -``` - \ No newline at end of file diff --git a/docs/csharp/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml1.md b/docs/csharp/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml1.md deleted file mode 100644 index 27838a95b4907..0000000000000 --- a/docs/csharp/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml1.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: "Preserving White Space while Loading or Parsing XML" -ms.date: 07/20/2015 -ms.assetid: f3ff58c4-55aa-4fcd-b933-e3a2ee6e706c ---- -# Preserving White Space while Loading or Parsing XML -This topic describes how to control the white-space behavior of [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)]. - - A common scenario is to read indented XML, create an in-memory XML tree without any white space text nodes (that is, not preserving white space), perform some operations on the XML, and then save the XML with indentation. When you serialize the XML with formatting, only significant white space in the XML tree is preserved. This is the default behavior for [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)]. - - Another common scenario is to read and modify XML that has already been intentionally indented. You might not want to change this indentation in any way. To do this in [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)], you preserve white space when you load or parse the XML and disable formatting when you serialize the XML. - - This topic describes the white-space behavior of methods that populate XML trees. For information about controlling white space when you serialize XML trees, see [Preserving White Space While Serializing](./preserving-white-space-while-serializing.md). - -## Behavior of Methods that Populate XML Trees - The following methods in the and classes populate an XML tree. You can populate an XML tree from a file, a , an , or a string: - -- - -- - -- - -- - - If the method does not take as an argument, the method will not preserve insignificant white space. - - In most cases, if the method takes as an argument, you can optionally preserve insignificant white space as text nodes in the XML tree. However, if the method is loading the XML from an , then the determines whether white space will be preserved or not. Setting will have no effect. - - With these methods, if white space is preserved, insignificant white space is inserted into the XML tree as nodes. If white space is not preserved, text nodes are not inserted. - - You can create an XML tree by using an . Nodes that are written to the are populated in the tree. However, when you build an XML tree using this method, all nodes are preserved, regardless of whether the node is white space or not, or whether the white space is significant or not. - \ No newline at end of file diff --git a/docs/standard/linq/catch-parsing-errors.md b/docs/standard/linq/catch-parsing-errors.md new file mode 100644 index 0000000000000..040391725187e --- /dev/null +++ b/docs/standard/linq/catch-parsing-errors.md @@ -0,0 +1,62 @@ +--- +title: "How to catch parsing errors - LINQ to XML" +description: Learn how to detect badly formed or invalid XML. +ms.date: 7/20/2015 +dev_langs: + - "csharp" + - "vb" +ms.assetid: bfb612d4-5605-48ef-8c93-915cf9d5dcfb +--- + +# How to catch parsing errors (LINQ to XML) + +This article shows how to detect badly formed or invalid XML in C# or Visual Basic. + +LINQ to XML is implemented using . If badly formed or invalid XML is passed to LINQ to XML, the underlying class will throw an exception. The various methods that parse XML, such as , do not catch the exception; the exception can then be caught by your application. + +## Example: Parse invalid XML + +The following code tries to parse invalid XML. + +```csharp +try { + XElement contacts = XElement.Parse( + @" + + Jim Wilson + + "); + + Console.WriteLine(contacts); +} +catch (System.Xml.XmlException e) +{ + Console.WriteLine(e.Message); +} +``` + +```vb +Try + Dim contacts As XElement = XElement.Parse("" & vbCrLf & _ + " " & vbCrLf & _ + " Jim Wilson" & vbCrLf & _ + " " & vbCrLf & _ + "") + + Console.WriteLine(contacts) +Catch e As System.Xml.XmlException + Console.WriteLine(e.Message) +End Try +``` + +Because of the invalid end tag ``, the example throws the following exception: + +```console +The 'Contacts' start tag on line 1 doesn't match the end tag of 'Contcts'. Line 5, position 13. +``` + +For information about the exceptions that the , , , and methods throw, see the documentation. + +## See also + +- [How to parse a string (LINQ to XML)](parse-string.md) diff --git a/docs/standard/linq/create-tree-xmlreader.md b/docs/standard/linq/create-tree-xmlreader.md new file mode 100644 index 0000000000000..0ca11cc809009 --- /dev/null +++ b/docs/standard/linq/create-tree-xmlreader.md @@ -0,0 +1,66 @@ +--- +title: "How to create a tree from an XmlReader - LINQ to XML" +description: Learn how to create an XML tree directly from an XmlReader. +ms.date: 07/20/2015 +dev_langs: + - "csharp" + - "vb" +ms.assetid: 60951c9c-7087-406c-b5bb-c60e58609b21 +--- + +# How to create a tree from an XmlReader (LINQ to XML) + +This article shows how to create an XML tree directly from an in C# or Visual Basic. To create an from an , you position the on an element node. The will skip comments and processing instructions, but if the is positioned on a text node, an error will be thrown. To avoid such errors, position the on an element before you create an XML tree from the . + +## Example: Load XElement object from an XmlReader object + +This example uses the XML document [Sample XML file: Books (LINQ to XML)](sample-xml-file-books.md). + +The following code creates a object, reads nodes until it finds the first element node, and loads the object. + +```csharp +XmlReader r = XmlReader.Create("books.xml"); +while (r.NodeType != XmlNodeType.Element) + r.Read(); +XElement e = XElement.Load(r); +Console.WriteLine(e); +``` + +```vb +Dim r As XmlReader = XmlReader.Create("books.xml") +Do While r.NodeType <> XmlNodeType.Element + r.Read() +Loop +Dim e As XElement = XElement.Load(r) +Console.WriteLine(e) +``` + +The example produces this output: + +```xml + + + Garghentini, Davide + XML Developer's Guide + Computer + 44.95 + 2000-10-01 + An in-depth look at creating applications + with XML. + + + Garcia, Debra + Midnight Rain + Fantasy + 5.95 + 2000-12-16 + A former architect battles corporate zombies, + an evil sorceress, and her own childhood to become queen + of the world. + + +``` + +## See also + +- [Parse XML](parse-string.md) diff --git a/docs/standard/linq/functional-construction.md b/docs/standard/linq/functional-construction.md index 48272a0a5109f..b981846c654d4 100644 --- a/docs/standard/linq/functional-construction.md +++ b/docs/standard/linq/functional-construction.md @@ -95,5 +95,5 @@ The example produces this output: ## See also -- [Create XML Trees in C#](create-xml-trees.md) -- [XML literals in Visual Basic](xml-literals.md) +- [Create XML Trees in C# (LINQ to XML)](create-xml-trees.md) +- [XML literals in Visual Basic (LINQ to XML)](xml-literals.md) diff --git a/docs/standard/linq/linq-xml-vs-dom.md b/docs/standard/linq/linq-xml-vs-dom.md index fa73441d52f31..4b8a66ef03859 100644 --- a/docs/standard/linq/linq-xml-vs-dom.md +++ b/docs/standard/linq/linq-xml-vs-dom.md @@ -162,7 +162,7 @@ Another problem with the DOM is that it doesn't let you change the name of a nod ## Static method support for loading XML -LINQ to XML lets you load XML by using static methods, instead of instance methods. This simplifies loading and parsing. For more information, see [How to load XML from a file](load-xml-file.md). +LINQ to XML lets you load XML by using static methods, instead of instance methods. This simplifies loading and parsing. For more information, see [How to load XML from a file (LINQ to XML)](load-xml-file.md). ## Removal of support for DTD constructs diff --git a/docs/visual-basic/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md b/docs/standard/linq/load-xml-file.md similarity index 50% rename from docs/visual-basic/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md rename to docs/standard/linq/load-xml-file.md index 7b39d8519a757..c2f99feb1f667 100644 --- a/docs/visual-basic/programming-guide/concepts/linq/how-to-load-xml-from-a-file.md +++ b/docs/standard/linq/load-xml-file.md @@ -1,24 +1,34 @@ --- -title: "How to: Load XML from a File" +title: "How to load XML from a file - LINQ to XML" +description: Learn how to load XML from a file. ms.date: 07/20/2015 -ms.assetid: e2d337ad-8ac8-4671-b694-30e5ca1413b7 +dev_langs: + - "csharp" + - "vb" +ms.assetid: 3ed38487-8028-4209-9872-c8dce0ed4dfe --- -# How to: Load XML from a File (Visual Basic) -This topic shows how to load XML from a URI by using the method. +# How to load XML from a file (LINQ to XML) -## Example +This article shows how to load XML from a file in C# and Visual Basic using the method. -The following example shows how to load an XML document from a file. The following example loads books.xml and outputs the XML tree to the console. +## Example: Load XML document from a file -This example uses the following XML document: [Sample XML File: Books (LINQ to XML)](../../../../visual-basic/programming-guide/concepts/linq/sample-xml-file-books-linq-to-xml.md). +The following example shows how to load an XML document from a file by providing with the URI that references the file. The example loads books.xml and outputs the XML tree to the console. + +The contents of books.xml are shown in [Sample XML file: Books (LINQ to XML)](sample-xml-file-books.md). + +```csharp +XElement booksFromFile = XElement.Load(@"books.xml"); +Console.WriteLine(booksFromFile); +``` ```vb Dim booksFromFile As XElement = XElement.Load("books.xml") Console.WriteLine(booksFromFile) ``` -This code produces the following output: +The example produces this output: ```xml @@ -43,7 +53,3 @@ This code produces the following output: ``` - -## See also - -- [Parsing XML (Visual Basic)](../../../../visual-basic/programming-guide/concepts/linq/parsing-xml.md) diff --git a/docs/standard/linq/preserve-white-space-loading-parsing-xml.md b/docs/standard/linq/preserve-white-space-loading-parsing-xml.md new file mode 100644 index 0000000000000..4597c00f6ab8c --- /dev/null +++ b/docs/standard/linq/preserve-white-space-loading-parsing-xml.md @@ -0,0 +1,33 @@ +--- +title: "Preserve white space while loading or parsing XML - LINQ to XML" +description: Learn how to control the white-space behavior of methods that populate XML trees. +ms.date: 07/20/2015 +ms.assetid: f3ff58c4-55aa-4fcd-b933-e3a2ee6e706c +--- + +# Preserve white space while loading or parsing XML (LINQ to XML) + +This article describes how to control the white-space behavior of LINQ to XML. + +A common scenario is to read indented XML, create an in-memory XML tree without any white space text nodes (that is, not preserving white space), do some operations on the XML, and then save the XML with indentation. When you serialize the XML with formatting, only significant white space in the XML tree is preserved. This is the default behavior for LINQ to XML. + +Another common scenario is to read and modify XML that has already been intentionally indented. You might not want to change this indentation in any way. To do this in LINQ to XML, you preserve white space when you load or parse the XML and disable formatting when you serialize the XML. + +This article describes the white-space behavior of methods that populate XML trees. For information about controlling white space when you serialize XML trees, see [Preserve white space while serializing (LINQ to XML)](preserve-white-space-serializing.md). + +## Behavior of methods that populate XML trees + +The following methods in the and classes populate an XML tree. You can populate an XML tree from a file, a , an , or a string: + +- +- +- +- + +If the method doesn't take as an argument, the method won't preserve insignificant white space. + +In most cases, if the method takes as an argument, you can optionally preserve insignificant white space as text nodes in the XML tree. However, if the method is loading the XML from an , then the determines whether white space will be preserved or not. Setting will have no effect. + +With these methods, if white space is preserved, insignificant white space is inserted into the XML tree as nodes. If white space isn't preserved, text nodes aren't inserted. + +You can create an XML tree by using an . Nodes that are written to the are populated in the tree. However, when you build an XML tree using this method, all nodes are preserved, regardless of whether the node is white space or not, or whether the white space is significant or not. diff --git a/docs/standard/linq/toc.yml b/docs/standard/linq/toc.yml index 5f68ee042eba3..4c1e351436ca7 100644 --- a/docs/standard/linq/toc.yml +++ b/docs/standard/linq/toc.yml @@ -304,8 +304,8 @@ href: mixed-declarative-code-imperative-code-bugs.md - name: "How to stream XML fragments with access to header information" href: stream-xml-fragments-access-header-information.md - - name: "How to do streaming transform of large XML documents" - href: do-streaming-transform-large-xml-documents.md + - name: "How to perform streaming transform of large XML documents" + href: perform-streaming-transform-large-xml-documents.md - name: "How to read and write an encoded document" href: read-write-encoded-document.md - name: Use XSLT to transform an XML tree diff --git a/docs/standard/linq/xml-literals.md b/docs/standard/linq/xml-literals.md index 6ce6ae3683f59..068b6d86268e8 100644 --- a/docs/standard/linq/xml-literals.md +++ b/docs/standard/linq/xml-literals.md @@ -201,4 +201,4 @@ Child2 was attached ## See also -- [Functional construction](functional-construction.md) +- [Functional construction (LINQ to XML)](functional-construction.md) diff --git a/docs/visual-basic/programming-guide/concepts/linq/how-to-catch-parsing-errors.md b/docs/visual-basic/programming-guide/concepts/linq/how-to-catch-parsing-errors.md deleted file mode 100644 index 24a116af0a39f..0000000000000 --- a/docs/visual-basic/programming-guide/concepts/linq/how-to-catch-parsing-errors.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: "How to: Catch Parsing Errors" -ms.date: 07/20/2015 -ms.assetid: 22e9068e-ea58-447b-816e-cd1852c11787 ---- -# How to: Catch Parsing Errors (Visual Basic) -This topic shows how to detect badly formed or invalid XML. - - [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)] is implemented using . If badly formed or invalid XML is passed to [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)], the underlying class will throw an exception. The various methods that parse XML, such as , do not catch the exception; the exception can then be caught by your application. - - Note that you cannot get parse errors if you use XML literals. The Visual Basic compiler will catch errors of badly formed or invalid XML. - -## Example - The following code tries to parse invalid XML: - -```vb -Try - Dim contacts As XElement = XElement.Parse("" & vbCrLf & _ - " " & vbCrLf & _ - " Jim Wilson" & vbCrLf & _ - " " & vbCrLf & _ - "") - - Console.WriteLine(contacts) -Catch e As System.Xml.XmlException - Console.WriteLine(e.Message) -End Try -``` - - When you run this code, it throws the following exception: - -```console -The 'Contacts' start tag on line 1 does not match the end tag of 'Contcts'. Line 5, position 13. -``` - - For information about the exceptions that you can expect the , , , and methods to throw, see the documentation. - -## See also - -- [Parsing XML (Visual Basic)](../../../../visual-basic/programming-guide/concepts/linq/parsing-xml.md) diff --git a/docs/visual-basic/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md b/docs/visual-basic/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md deleted file mode 100644 index 501d91e6f2e48..0000000000000 --- a/docs/visual-basic/programming-guide/concepts/linq/how-to-create-a-tree-from-an-xmlreader.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: "How to: Create a Tree from an XmlReader" -ms.date: 07/20/2015 -ms.assetid: 6de683d8-177d-402b-b0de-d0539f1ce5d8 ---- -# How to: Create a Tree from an XmlReader (Visual Basic) - -This topic shows how to create an XML tree directly from an . To create an from an , you must position the on an element node. The will skip comments and processing instructions, but if the is positioned on a text node, an error will be thrown. To avoid such errors, always position the on an element before you create an XML tree from the . - -## Example - -This example uses the following XML document: [Sample XML File: Books (LINQ to XML)](../../../../visual-basic/programming-guide/concepts/linq/sample-xml-file-books-linq-to-xml.md). - -The following code creates an `T:System.Xml.XmlReader` object, and then reads nodes until it finds the first element node. It then loads the object. - -```vb -Dim r As XmlReader = XmlReader.Create("books.xml") -Do While r.NodeType <> XmlNodeType.Element - r.Read() -Loop -Dim e As XElement = XElement.Load(r) -Console.WriteLine(e) -``` - -This example produces the following output: - -```xml - - - Garghentini, Davide - XML Developer's Guide - Computer - 44.95 - 2000-10-01 - An in-depth look at creating applications - with XML. - - - Garcia, Debra - Midnight Rain - Fantasy - 5.95 - 2000-12-16 - A former architect battles corporate zombies, - an evil sorceress, and her own childhood to become queen - of the world. - - -``` - -## See also - -- [Parsing XML (Visual Basic)](../../../../visual-basic/programming-guide/concepts/linq/parsing-xml.md) diff --git a/docs/visual-basic/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml.md b/docs/visual-basic/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml.md deleted file mode 100644 index 2bd69577114d7..0000000000000 --- a/docs/visual-basic/programming-guide/concepts/linq/preserving-white-space-while-loading-or-parsing-xml.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: "Preserving White Space while Loading or Parsing XML2" -ms.date: 07/20/2015 -ms.assetid: ef6518e0-2c8d-462c-8b92-a16e9dc737ad ---- -# Preserving White Space while Loading or Parsing XML -This topic describes how to control the white space behavior of [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)]. - - A common scenario is to read indented XML, create an in-memory XML tree without any white space text nodes (that is, not preserving white space), perform some operations on the XML, and then save the XML with indentation. When you serialize the XML with formatting, only significant white space in the XML tree is preserved. This is the default behavior for [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)]. - - Another common scenario is to read and modify XML that has already been intentionally indented. You might not want to change this indentation in any way. To do this in [!INCLUDE[sqltecxlinq](~/includes/sqltecxlinq-md.md)], you preserve white space when you load or parse the XML and disable formatting when you serialize the XML. - - This topic describes the white space behavior of methods that populate XML trees. For information about controlling white space when you serialize XML trees, see [Preserving White Space While Serializing](../../../../visual-basic/programming-guide/concepts/linq/preserving-white-space-while-serializing.md). - -## Behavior of Methods that Populate XML Trees - The following methods in the and classes populate an XML tree. You can populate an XML tree from a file, a , an , or a string: - -- - -- - -- - -- - - If the method does not take as an argument, the method will not preserve insignificant white space. - - In most cases, if the method takes as an argument, you can optionally preserve insignificant white space as text nodes in the XML tree. However, if the method is loading the XML from an , then the determines whether white space will be preserved or not. Setting will have no effect. - - With these methods, if white space is preserved, insignificant white space is inserted into the XML tree as nodes. If white space is not preserved, text nodes are not inserted. - - You can create an XML tree by using an . Nodes that are written to the are populated in the tree. However, when you build an XML tree using this method, all nodes are preserved, regardless of whether the node is white space or not, or whether the white space is significant or not. - -## See also - -- [Parsing XML (Visual Basic)](../../../../visual-basic/programming-guide/concepts/linq/parsing-xml.md)