Reputation: 99
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.
Upvotes: 0
Views: 45
Reputation: 34421
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"));
}
}
}
Upvotes: 1