Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我需要编辑和更新的XML文件从数据库VB网络_Xml_Vb.net_Xpath - Fatal编程技术网

我需要编辑和更新的XML文件从数据库VB网络

我需要编辑和更新的XML文件从数据库VB网络,xml,vb.net,xpath,Xml,Vb.net,Xpath,我有一个数据库,其中包含大量XML文件作为字符串,我想更新这些文件,但仅在某些情况下,例如,我有以下文件: <Activity mc:Ignorable="sads sap" x:Class="EmptyTask" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ...

我有一个数据库,其中包含大量XML文件作为字符串,我想更新这些文件,但仅在某些情况下,例如,我有以下文件:

<Activity mc:Ignorable="sads sap" x:Class="EmptyTask"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 ...
                  <t1:ReadProductParameterValue DisplayName="Normes tares" sap:VirtualizedContainerService.HintSize="200,22" Parameter="Normes tares" Value="[NormeTare]">
                    <sap:WorkflowViewStateService.ViewState>
                      <scg:Dictionary x:TypeArguments="x:String, x:Object">
                        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                      </scg:Dictionary>
                    </sap:WorkflowViewStateService.ViewState>
                  </t1:ReadProductParameterValue>
                  ...
                      <t1:ReadProductParameterValue DisplayName="Normes volumes" sap:VirtualizedContainerService.HintSize="200,22" Parameter="Normes volumes" Value="[NormeVol]">
                        <sap:WorkflowViewStateService.ViewState>
                          <scg:Dictionary x:TypeArguments="x:String, x:Object">
                            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                          </scg:Dictionary>
                        </sap:WorkflowViewStateService.ViewState>
                      </t1:ReadProductParameterValue>
                      ...
     sap:VirtualizedContainerService.HintSize="200,22" Increment="1" Variable="OccurencePesee">

                                                                          <sap:WorkflowViewStateService.ViewState>
                                                                            <scg:Dictionary x:TypeArguments="x:String, x:Object">
                                                                              <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                                                                            </scg:Dictionary>
                                                                          </sap:WorkflowViewStateService.ViewState>
                                                                        </t1:IncrementSharedVariableValue>
...
...
...                                                                                                                      <t1:WriteSharedVariableValue BatchVariableName="{x:Null}" DisplayName="rec_tare_ou_vol_hors_norme" sap:VirtualizedContainerService.HintSize="200,22" Value="[local_tare_ou_vol_hors_norme]" Variable="rec_tare_ou_vol_hors_norme">
                                                                                                                        <sap:WorkflowViewStateService.ViewState>
                                                                                                                          <scg:Dictionary x:TypeArguments="x:String, x:Object">
                                                                                                                            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
                                                                                                                          </scg:Dictionary>
                                                                                                                        </sap:WorkflowViewStateService.ViewState>
                                                                                                                      </t1:WriteSharedVariableValue>
                                                                                                                      <FlowStep.Next>
...
...
...                                                                                                                          <t1:ExecuteTask BackColor="{x:Null}" DateToExecute="{x:Null}" LowLevel="{x:Null}" UpLevel="{x:Null}" BypassVariable="{x:Null}" AutoStart="True" DisplayName="A118. Stand by BP (v.1)" Grouping="" sap:VirtualizedContainerService.HintSize="250,55" Label="Stand by BP (v.1)" Tache="8529de33-9721-4449-83d4-79b7fd5590f0" LockingTask="True" TypePoste="Remplissage">
                                                                                                                            <t1:ExecuteTask.Arguments>
                                                                                                                              ...
  </Flowchart>
</Activity>

真的
...
...
...                                                                                                                      
真的
...
...
...                                                                                                                          
...
在这里,我想在这个确切的节点中进行修改

<t1:ExecuteTask BackColor="{x:Null}" DateToExecute="{x:Null}" LowLevel="{x:Null}" UpLevel="{x:Null}" BypassVariable="{x:Null}" AutoStart="True" DisplayName="A118. Stand by BP (v.1)" Grouping="" sap:VirtualizedContainerService.HintSize="250,55" Label="Stand by BP (v.1)" Tache="8529de33-9721-4449-83d4-79b7fd5590f0" LockingTask="True" TypePoste="Remplissage">
                                                                                                                                <t1:ExecuteTask.Arguments>

“ExecuteTask”并将其替换为“ExTasks”,将“Tache”替换为“TaskID”,然后将其重新保存到my DB 如何使用VB.NET..进行此操作?
我是通过使用一些sql命令来实现的,但有时,它会替换我不想修改的名称,因此我必须具体指定要编辑和更新的节点。

使用xml linq非常简单:

Imports System.Xml
Imports System.Xml.Linq
Module Module1
    Const FILENAME As String = "c:\temp\test.xml"
    Sub Main()
        Dim doc As XDocument = XDocument.Load(FILENAME)

        Dim executeTask As XElement = doc.Descendants().Where(Function(x) x.Name.LocalName = "ExecuteTask").FirstOrDefault()
        executeTask.SetAttributeValue("BackColor", "purple")
    End Sub

End Module