1

WriteXmlString()これは、 ofからの出力として取得した xmlですInfragistics ultrawebtreeInfragistics ultrawebtreeこれを使用して、同じ構造の別のものを作成しています。しかし、ここでは<Url>something.aspx..</Url>. こうあってほしい<Url><\Url>。では、どうすれば削除できるのでしょうか。これは文字列として取得します。だから私は使用しRegex.Replace()ました。ただし、特定の条件では機能しますが、場合によっては、いくつかの xml タグを削除して xml を破壊し、タグの欠落により xml が無効になります。この表現を使用して<Url>\S*</Url>、Url の内容を回避しました。どんな助けでも非常に役に立ちます。前もって感謝します。

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
- <InfragisticsServerTree XmlVersion="1.0">
  - <uwtModule>
    - <ProjectProperties>
      <ComponentTarget>ClassicTree</ComponentTarget>
      <BrowserTarget>Auto</BrowserTarget>
    </ProjectProperties>
    - <TreeProperties>
      <MaxDataBindDepth>-1</MaxDataBindDepth>
      <Name>uwtModule</Name>
      <Indentation>20</Indentation>
      <SubMenuImage>igNone</SubMenuImage>
      <LoadOnDemandPrompt>
        <b>Loading...</b>
      </LoadOnDemandPrompt>
      <ExpandAnimation>Decelerate</ExpandAnimation>
      <ExpandOnClick>false</ExpandOnClick>
      <CompactRendering>false</CompactRendering>
      <RenderAnchors>false</RenderAnchors>
      - <Style>
        <ForeColor>-16777216</ForeColor>
        <BorderColor>-4144960</BorderColor>
        <BorderStyle>None</BorderStyle>
        <BorderWidth>1px</BorderWidth>
        - <Font>
          <Name>Arial</Name>
          - <Names>
            <Name>Arial</Name>
          </Names>
          <Size>11px</Size>
        </Font>
        <Height>425px</Height>
        <Width>97%</Width>
        - <Padding>
          <Top>5px</Top>
          <Left>5px</Left>
          <Right>5px</Right>
          <Bottom>5px</Bottom>
        </Padding>
      </Style>
      - <SelectedNodeStyle>
        <BackColor>-2894893</BackColor>
        <ForeColor>-16777216</ForeColor>
        - <Padding>
          <Top>2px</Top>
          <Left>2px</Left>
          <Right>2px</Right>
          <Bottom>2px</Bottom>
        </Padding>
      </SelectedNodeStyle>
    </TreeProperties>
    <Styles />
    - <Levels>
      - <Level>
        <Number>0</Number>
      </Level>
    </Levels>
- <Nodes>
  - <Node>
    <Text>123</Text>
    <Url>ModuleEdit.aspx?ModuleID=965</Url>
    <Target>main</Target>
    <Tag>965</Tag>
    <Title>AccptChangesPerfPM</Title>
    <Expanded>true</Expanded>
    - <Nodes>
      - <Node>
        <Text>111</Text>
        <Url>123.aspx?e=965 </Url>
        <Target>main</Target>
        <Tag>TL_-99999</Tag>
      </Node>
      - <Node>
        <Text>werrv</Text>
        <Url>1dfee.aspx?qwe=9er65</Url>
        <Target>main</Target>
        <Tag>12DDfe</Tag>
      </Node>
      - <Node>
        <Text>q2233</Text>
        <Target>main</Target>
        <Tag>TL_1015</Tag>
        <Title>Topic_1</Title>
        <ShowExpand>true</ShowExpand>
        - <Nodes>
          - <Node>
            <Text>T1</Text>
            <Url>w3345_954y65.aspx?ID=965er</Url>
            <Target>main</Target>
            - <Style>
              <ForeColor>-16777216</ForeColor>
            </Style>
            <Tag>82355</Tag>
            <Title>T1</Title>
          </Node>
          - <Node>
            <Text>T2</Text>
            <Url>23_7811.aspx?ID=3u65</Url>
            <Target>main</Target>
            - <Style>
              <ForeColor>-16777216</ForeColor>
            </Style>
            <Tag>82356</Tag>
            <Title>T2</Title>
          </Node>
          - <Node>
            <Text>T3</Text>
            <Url>we456_9.aspx?ID=4r56</Url>
            <Target>main</Target>
            - <Style>
              <ForeColor>-16777216</ForeColor>
            </Style>
            <Tag>82357</Tag>
            <Title>T3</Title>
          </Node>
        </Nodes>
      </Node>
    </Nodes>
  </Node>
</Nodes>
  </uwtModule>
</InfragisticsServerTree>
4

1 に答える 1

4

私のアドバイスは、正規表現を無視することです。

VB の XML クラスに移動してファイルから読み取り、ノードリストとノードを操作します。

開始するためのリンクを次に示します。

VB で XML を作成する#

VB で XML リテラルを変更する#

VB# の XML ファイルに対する複数のアクションのサンプル

[VB.NET] XML - ファイルの作成とマージ。ノードの編集、追加、および削除。

上記のリンクには、開く、編集する、作成する、マージする方法に関する詳細なドキュメントとサンプルがあります。

その下に、あなたが上で尋ねたことを行う方法があります.

string path = "./"; //your own path
string name = "Tempo"; //filename
XmlDocument f = new XmlDocument();
f.Load(path + name + ".xml");
XmlNodeList a = f.GetElementsByTagName("Url");
for (int i = 0; i < a.Count; i++)
{
    a[i].InnerText = ""  //This had the data inside <Url>...</Url>
}
    f.Save(path+name); //Edited to add the save
于 2012-04-05T15:20:29.843 に答える