how to access xml elements with specific attribues

  • Thread starter Thread starter Policy standard local admin account with Active Di
  • Start date Start date
P

Policy standard local admin account with Active Di

Guest
Hello

I have tried to made a code to find a specific attribute, this time using a xml.linq library.

please, follow the code below


I have created a class Funtions and inside I created the function which is called from GetRecordsWithSpecioficAttribut. I created the class fn with Functions fn = new Functions(); and I called with fn.GetRecordsWitrhSpecificAttributs();


However, I have receive an exception when I try to find one specific attribut inside several nodes. The code works if I find a high level node attribut


Let me attach the exception here



1441594.png




the xml file is

<?xml version="1.0"?>
<!-- WARNING: Those configuration represent the the default values for Sipelia SIP Server -->
<!-- WARNING: It is very recommended to make a backup of this file before doing any changes -->
<SipeliaSipServer>
<Configuration Version="2.0.7">
<!-- Values must be between 0 and 65535 -->
<MinimumPortRange Value="20000"/>
<MaximumPortRange Value="20500"/>
<!-- Value is in seconds. Minimum value is 40 -->
<TrunkStateTimeout Value="60"/>
<!-- Value is in seconds. Minimum value is 0 -->
<DeviceRegistrationMargin Value="60"/>
<!-- Value is enabled or disabled. Used to resolve invalid SIP contact header fields. -->
<InvalidContactFieldResolution Enabled="False" />
<!-- Sipelia SIP Server Audio and Video codecs -->
<!-- WARNING: Edit only the 'Enabled' attribute value -->
<Codecs>
<VideoCodecs>
<Codec Name="H263-1998" Enabled="True"/>
<Codec Name="H264" Enabled="True" KeyframeGenerationInterval="4"/> <!-- KeyframeGenerationInterval: When transcoding to H264 this value will be used to generate the keyframes. The default value for K-frame is 4s. -->
<Codec Name="H263" Enabled="True"/>
</VideoCodecs>
<AudioCodecs>
<Codec Name="PCMA" Enabled="True"/>
<Codec Name="PCMU" Enabled="True"/>
<Codec Name="telephone-event" Enabled="True"/>
<Codec Name="iLBC" Enabled="True"/>
<Codec Name="G722" Enabled="True"/>
<Codec Name="GSM" Enabled="True"/>
<Codec Name="SPEEX_Narrowband" Enabled="False"/>
<Codec Name="SPEEX_Wideband" Enabled="True"/>
<Codec Name="SPEEX_Ultrawideband" Enabled="True"/>
<Codec Name="L16" Enabled="False"/>
<Codec Name="L16_44_1" Enabled="True"/>
<Codec Name="G728" Enabled="False"/>
<Codec Name="G723" Enabled="False"/>
<Codec Name="G726-16" Enabled="True"/>
<Codec Name="G726-24" Enabled="False"/>
<Codec Name="G726-32" Enabled="False"/>
<Codec Name="G726-40" Enabled="False"/>
<Codec Name="G729" Enabled="False"/>
</AudioCodecs>
</Codecs>
<!-- The default method name is 'None' -->
<NatTraversalMethod Value="None"/>
</Configuration>
</SipeliaSipServer>



I will appreciate any support


thanks


Jose




namespace xmlLInqConsole
{
class Functions
{


public void GetRecordsWithSpecificAttributs()
{

XElement GetAttri = XElement.Load(@"C:\mis documentos\c#\xml\SipServer.config");

IEnumerable<XElement> sipeliafile = GetAttri.Elements();






var GetCodec = from codec in sipeliafile
where codec.Element("Codec").Attribute("Name").Value == "PCMA"
select codec;

foreach(XElement codec in GetCodec)
{
Console.WriteLine(codec);
}






}


}
}

Continue reading...
 

Similar threads

P
Replies
0
Views
118
Policy standard local admin account with Active Di
P
P
Replies
0
Views
67
Policy standard local admin account with Active Di
P
Back
Top