0

Should be easy, but i have no idea how to do it:

I have id number like this:

ID1000

and i want to get this:

                <xf:instance id="etykiety_ID1000" xmlns="">
                    <sek>
                        <etykiety_ref>
                            <opt>
                                <item>dokument wymagany</item>
                                <value>1</value>
                            </opt>
                            <opt>
                                <item>dokument niewymagany</item>
                                <value>2</value>
                            </opt>
                            <opt>
                                <item>potwierdzenie sprawdzenia</item>
                                <value>3</value>
                            </opt>
                        </etykiety_ref>
                    </sek>
                </xf:instance>

this also:

<xf:bind id="ID1000"
    nodeset="wnio:TrescDokumentu/wnio:Wartosc/wnio:ID1000" relevant="true()"/>

but not this:

                <xf:instance id="etykiety_ID56" xmlns="">
                    <sek>
                        <etykiety_ref>
                            <opt>
                                <item>dokument wymagany</item>
                                <value>1</value>
                            </opt>
                            <opt>
                                <item>dokument niewymagany</item>
                                <value>2</value>
                            </opt>
                            <opt>
                                <item>potwierdzenie sprawdzenia</item>
                                <value>3</value>
                            </opt>
                        </etykiety_ref>
                    </sek>
                </xf:instance>

Other words, i want to get all ID1000 occurences with all artibutes and stuff inside.

Sorry if my question is basic knowledge, I'm begginer.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Qentinios
  • 89
  • 1
  • 8

1 Answers1

1

Use XML Linq

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);
            var results = doc.Root.Elements()
                .Where(x => x.Attribute("id").Value.EndsWith("ID1000"));
        }
    }
}​
jdweng
  • 33,250
  • 2
  • 15
  • 20