Reads a value or values from lines of XML
Namespace: MSBuild.Community.Tasks.Xml
Assembly: MSBuild.Community.Tasks (in MSBuild.Community.Tasks.dll)
Syntax
Example
Read an attribute value by selecting it with an XPath expression:
Copy Code | |
---|---|
<ReadLinesFromFile File="web.config"> <Output TaskParameter="Lines" ItemName="FileContents" /> </ReadLinesFromFile> <XmlQuery Lines="@(FileContents)" XPath = "/configuration/system.web/compilation/@defaultLanguage"> <Output TaskParameter="Values" PropertyName="CompilationLanguage" /> </XmlQuery> <Message Text="The default language is $(CompilationLanguage)." /> |
Copy Code | |
---|---|
<XmlQuery XmlFileName="$(MSBuildProjectDirectory)\web.config" XPath = "/configuration/system.web/compilation"> <Output TaskParameter="Values" ItemName="CompilationElement" /> </XmlQuery> <Message Text="The default language is: $(CompilationElement.defaultLanguage)." /> <Message Text="Debug is enabled: $(CompilationElement.debug)." /> |
Copy Code | |
---|---|
<ReadLinesFromFile File="web.config"> <Output TaskParameter="Lines" ItemName="FileContents" /> </ReadLinesFromFile> <XmlQuery Lines="@(FileContents)" XPath = "/configuration/singleValue/LastName"> <Output TaskParameter="Values" PropertyName="LastNameElement" /> </XmlQuery> <Message Text="The last name is %(LastNameElement._value)" /> |
Remarks
Use the Lines property (possibly populated from the the ReadLinesFromFile task) if you want to perform multiple queries against some XML in memory. Use the XmlFileName property to query a large XML file.
An XPath expression can return multiple nodes in the
When the XPath expression resolves to an element node, all of the attributes of the element are added as metadata to the returned
Reserved Property | |
---|---|
_value | The value of the node (non-xml text between the opening and closing tags). |
_innerXml | The markup representing the children of this node. |
_outerXml | The markup representing this node and all its child nodes. |
Inheritance Hierarchy
Thread Safety
Public static (Shared in Visual Basic)staticShared members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
See Also
Documentation version 1.0.0.0.