The difference between XmlRead vs XmlPeek ?

XmlPeek:
Read inner text.
Built-in support by MSBuild in dotNet Framework.

XmlRead:
Do not read inner text.
Need MSBuild Community Task.

Example:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="MAIN" ToolsVersion="4.0">
  <!--<Import Project="$(MSBuildExtensionsPath)\MSBuildContrib\MSBuildContrib.Tasks"/>-->
  <!--<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.tasks"/>-->
  <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />

  <Target Name="MAIN">
    <XmlPeek Namespaces="&lt;Namespace Prefix='msb' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/&gt;"
             XmlInputPath="$(MSBuildProjectFile)"
             Query="/msb:Project/msb:Import">
      <Output TaskParameter="Result" ItemName="Peeked" />
    </XmlPeek>
    <Message Text="111: @(Peeked)"/>

    <XmlRead Prefix='msb' Namespace='http://schemas.microsoft.com/developer/msbuild/2003'
             XmlFileName="$(MSBuildProjectFile)"
             XPath="/msb:Project/msb:Import" >
      <Output TaskParameter="Value" ItemName="Peeked2" />
    </XmlRead>
    <Message Text="222: @(Peeked2)"/>
  </Target>
</Project>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: