Show / Hide Table of Contents

Method XmlUtil.LoadElem(+ 1 overload)


Overload

Loads XML file in a safer way. Uses System.Xml.Linq.XElement.Load and filesystem.waitIfLocked.

public static XElement LoadElem(string file, LoadOptions options = LoadOptions.None)
Parameters
file  (string)

File. Must be full path. Can contain environment variables etc, see pathname.expand. If starts with '<', loads from XML string instead.

options  (LoadOptions)
Returns
XElement
Exceptions
ArgumentException

Not full path.

Exception

Exceptions of System.Xml.Linq.XElement.Load.

Remarks

Unlike System.Xml.Linq.XElement.Load, does not replace \r\n with \n.


Overload(top)

Loads XML file with a namespace.

public static XElement LoadElem(out XNamespace ns, string file, LoadOptions options = LoadOptions.None)
Parameters
ns  (XNamespace)

Receives the default namespace. Use it to get elements, like var x2 = x1.Element(ns + "name").

file  (string)

File. Must be full path. Can contain environment variables etc, see pathname.expand. If starts with '<', loads from XML string instead.

options  (LoadOptions)
Returns
XElement
Exceptions
ArgumentException

Not full path.

Exception

Exceptions of System.Xml.Linq.XElement.Load.

Remarks

Unlike System.Xml.Linq.XElement.Load, does not replace \r\n with \n.