Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all 935 articles
Browse latest View live

Error "Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'MSMQFSLoader..."

$
0
0

I have an XML file, I use XSD.exe to create a class Account.
When I tried to send a message of type class Account to MSMQ, I am getting this error:
"Unable to generate a temporary class (result=1). 
error CS0030: Cannot convert type 'MSMQFSLoader.AccountContactDetailsAddressesAddress[]' to 'MSMQFSLoader.AccountContactDetailsAddressesAddress' 
error CS0029: Cannot implicitly convert type 'MSMQFSLoader.AccountContactDetailsAddressesAddress' to 'MSMQFSLoader.AccountContactDetailsAddressesAddress[]'  "

What does the error mean, and how can I fix it ?
Thank you

This is my code:

Partial Public Class Account
    Private accountIdField As String
    Private contactDetailsField() As AccountContactDetails
:
    Public Property AccountId() As String
        Get
            Return Me.accountIdField
        End Get
        Set
            Me.accountIdField = value
        End Set
    End Property
    Public Property ContactDetails() As AccountContactDetails()
        Get
            Return Me.contactDetailsField
        End Get
        Set
            Me.contactDetailsField = value
        End Set
    End Property

Partial Public Class AccountContactDetails
     Private addressesField()() As AccountContactDetailsAddressesAddress
     Public Property Addresses() As AccountContactDetailsAddressesAddress()()
         Get
             Return Me.addressesField
         End Get
         Set
             Me.addressesField = value
         End Set
     End Property

Partial Public Class AccountContactDetailsAddressesAddress
     Private line1Field As String
     Private line2Field As String
     Public Property Line1() As String
         Get
             Return Me.line1Field
         End Get
         Set
             Me.line1Field = value
         End Set
     End Property

Dim eMsg As New System.Messaging.Message()
Dim oAccount As New Account

Dim xDoc = XElement.Load(myXMLFilePath)
For Each info As XElement In xDoc...<Addresses>
	Dim oContact As New AccountContactDetails
	Dim x As Integer = 0
        Dim o(x) As AccountContactDetailsAddressesAddress
	For Each addressInfo As XElement In info...<Address>
		Dim type As String = addressInfo...<Type>.Value
                Dim line1 As String = addressInfo...<Line1>.Value
                Dim line2 As String = addressInfo...<Line2>.Value
                o(x) = New AccountContactDetailsAddressesAddress
                o(x).Type = type
                o(x).Line1 = line1
                o(x).Line2 = line2
                x += 1
                ReDim Preserve o(x)
	Next
	oContact.Addresses = {o}
        Dim oc(0) As AccountContactDetails
        oc(0) = New AccountContactDetails
        oc(0) = oContact
        oAccount.ContactDetails = oc
Next
Try
	eMsg.Body = oAccount
        myMSMQ.Send(eMsg)  '---> ERROR HERE
Catch exc As Exception
        lblStatus.Text = "ProcessProduct - Error : " & exc.Message
Finally
End Try


Linq - How to Find Values

$
0
0

Hi I have a XML like the following and want to search/get Value based on model and prod.

Can anyone help me?

Thanks.

<Limits>
  <System model="001">
    <Limit prod="a123" value="10" />
    <Limit prod="b123" value="20" />   
  </System>
  <System model="002">
    <Limit prod="c123" value="7" /> 
    <Limit prod="d123" value="8" />    
  </System>
</Limits>

 

Controlling display width when applying a stylesheet to an xml file

$
0
0

I'm writing my first XSLT for a rather complicated XML.  

My problem is this.  What I'd like to do is limit the width of the display to the width of the browser window.  

The XSLT is still rather simple, the entire thing enclosed in a table.  I've tried setting the table width to 100% (no other width settings in the entire table) but still the displayed data is too wide for the screen and has a horizontal scroll bar.

How do I deal with this?

How to modify XML Encoding format to UTF-8

$
0
0

I am in Visual Studio 2012 using vb.net to serialize a message to XML. Everything looks fine except that the encoding is showing Windows-1252 in the XML file and I want it to be UTF-8. I have the encoding set to create it in UTF-8 format (see code below). So I am not sure what I am missing.

Dim xml_serializer As New System.Xml.Serialization.XmlSerializer(GetType(uapRequestType))

Dim ms As New System.IO.MemoryStream
Dim setting As New System.Xml.XmlWriterSettings
setting.Indent = True
setting.Encoding = System.Text.UTF8Encoding.Default
Dim writer As Xml.XmlWriter = Xml.XmlWriter.Create(ms, setting)
xml_serializer.Serialize(writer, request)
message = System.Text.Encoding.UTF8.GetString(ms.ToArray())

Embed video data in XML file

$
0
0
I wanted to embed video in a xml file and associate it with other pieces of data so I could pull it out, play it, and show the associated data and sync with a centralized source. Is this a typical thing to do or not a good idea?

Why does this code cause xsd.exe error, “You must implement a default accessor on System.Configuration.ConfigurationLockCollection”?

$
0
0

Hello MSDN users,

Iam trying to create an XSD from a dll that i created, but when i try to generate the XSD i get the following error message:

You must implement a default accessor on System.Configuration.ConfigurationLockCollection because it inherits from ICollection.

(Also tried different framework version (Did not work))

Command that gets executed:

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools>xsd "J:\ Programming\C#\NightBitsLogger Library\NightBitsLogger\bin\Debug\NightBitsLogger .dll"

Does anyone know what i have to do to have a default accessor for the ConfigurationLockCollection? (Because it seems that this is a bug in the .NET framework)

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Collections;

namespace NightBitsLogger.Configuration
{
    /// <summary>
    /// This class is an abstract class for a Collection of Config Elements
    /// </summary>
    /// <typeparam name="T"></typeparam>
    ///
    [ConfigurationCollection(typeof(ConfigurationItem), AddItemName = "ConfigurationElement" )]
    public abstract class CollectionOfElements<T> : ConfigurationElementCollection
        where T : ConfigurationItem, new()
    {
        /// <summary>
        /// Default Accessor for the collections
        /// </summary>
        [ConfigurationProperty("ConfigurationCollection", IsRequired = true)]
        public CollectionOfElements<ConfigurationItem> ConfigurationCollection
        {
            get
            {
                return base["ConfigurationCollection"] as CollectionOfElements<ConfigurationItem>;
            }
        }

        /// <summary>
        /// Create and return a new Configuration Element
        /// </summary>
        /// <returns></returns>
        protected override ConfigurationElement CreateNewElement()
        {
            return new T();
        }

        /// <summary>
        /// Return the element key.
        /// </summary>
        /// <param name="element"></param>
        /// <returns>(ConfigurationElement)key</returns>
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ConfigurationItem)element).Name;
        }

        /// <summary>
        /// Return the element with the given index
        /// Basic accessor for elements
        /// </summary>
        /// <param name="index"></param>
        /// <returns>[Element]byIndex</returns>
        public T this[int index]
        {
            get
            {
                return (T)BaseGet(index);
            }
            set
            {
                if (BaseGet(index) != null)
                {
                    BaseRemoveAt(index);
                }
                BaseAdd(index, value);
            }
        }

        /// <summary>
        /// Add a element to the collection
        /// </summary>
        /// <param name="collectionOfLoggerElement"></param>
        public void Add(T collectionOfLoggerElement)
        {
            BaseAdd(collectionOfLoggerElement);
        }

        /// <summary>
        /// Return the element with the given index
        /// </summary>
        /// <param name="name"></param>
        /// <returns>[Element]byName</returns>
        public new T this[string name]
        {
            get
            {
                return (T)BaseGet(name);
            }
        }
    }

    /// <summary>
    /// The CollectionOfLoggers Collection
    /// </summary>
    [ConfigurationCollection(typeof(CollectionOfLoggersElement), AddItemName = "CollectionOfLoggers", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class CollectionOfLoggers : CollectionOfElements<CollectionOfLoggersElement>
    {
        // Do nothing
    }

    /// <summary>
    /// The FileLogger Collection
    /// </summary>
    [ConfigurationCollection(typeof(FileLoggerElement), AddItemName = "fileLogger", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class FileLoggers : CollectionOfElements<FileLoggerElement>
    {
        // Do nothing
    }

    /// <summary>
    /// The RollingDateFileLogger Collection
    /// </summary>
    [ConfigurationCollection(typeof(RollingDateFileLoggerElement), AddItemName = "rollingDateFileLogger", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class RollingDateFileLoggers : CollectionOfElements<RollingDateFileLoggerElement>
    {
        // Do nothing
    }

    /// <summary>
    /// The RollingSizeFileLogger Collection
    /// </summary>
    [ConfigurationCollection(typeof(RollingSizeFileLoggerElement), AddItemName = "rollingSizeFileLogger", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class RollingSizeFileLoggers : CollectionOfElements<RollingSizeFileLoggerElement>
    {
        // Do nothing
    }

    /// <summary>
    /// The EmailLogger Collection
    /// </summary>
    [ConfigurationCollection(typeof(EmailLoggerElement), AddItemName = "emailLogger", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class EmailLoggers : CollectionOfElements<EmailLoggerElement>
    {
        // Do nothing
    }

    /// <summary>
    /// The SocketLogger Collection
    /// </summary>
    [ConfigurationCollection(typeof(SocketLoggerElement), AddItemName = "socketLogger", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class SocketLoggers : CollectionOfElements<SocketLoggerElement>
    {
        // Do nothing
    }

    /// <summary>
    /// The WindowsEventLogLogger Collection
    /// </summary>
    [ConfigurationCollection(typeof(WindowsEventLogLoggerElement), AddItemName = "WindowsEventLogLogger", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class WindowsEventLogLoggers : CollectionOfElements<WindowsEventLogLoggerElement>
    {
        // Do nothing
    }

    /// <summary>
    /// The ConsoleLogger Collection
    /// </summary>
    [ConfigurationCollection(typeof(ConsoleLoggerElement), AddItemName = "consoleLogger", CollectionType = ConfigurationElementCollectionType.BasicMap)]
    public class ConsoleLoggers : CollectionOfElements<ConsoleLoggerElement>
    {
        // Do nothing
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.ComponentModel;

namespace NightBitsLogger.Configuration
{
    /// <summary>
    /// This is the baseClass that represents a Config Item (Logger)
    /// </summary>
    public class ConfigurationItem : ConfigurationSection
    {
        /// <summary>
        /// Get the configuration
        /// </summary>
        /// <returns></returns>
        public static ConfigurationItem GetConfiguration()
        {
            ConfigurationItem configuration = ConfigurationManager.GetSection("NightBitsLogger.Configuration") as ConfigurationItem;

            if (configuration != null)
            {
                return configuration;
            }

            return new ConfigurationItem();
        }

        /// <summary>
        /// Occurs after the element is deserialized
        /// </summary>
        ///
        protected override void PostDeserialize()
        {
            base.PostDeserialize();
            Validate();
        }

        /// <summary>
        /// Validate the element. Throw a exception if not valid.
        /// </summary>
        protected virtual void Validate()
        {
            if ((IncludeCategories.Trim() != "") && (ExcludeCategories.Trim() != ""))
            {
                throw new ConfigurationErrorsException("logging element can have either includeCategories or excludeCategories, but not both.");
            }
        }

        /// <summary>
        /// Return true if the Logger Element is configured for the current machine; otherwise return false.
        /// </summary>
        /// <returns></returns>
        public bool IsConfiguredForThisMachine()
        {
            var machineNames = Machine.Trim().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            return (machineNames.Length == 0) || new List<string>(machineNames).Exists(name => name.Equals(Environment.MachineName, StringComparison.CurrentCultureIgnoreCase));
        }

        /// <summary>
        /// Get the name of the Logger
        /// </summary>
        [ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
        [Description("The name of the logger")]
        public string Name
        {
            get
            {
                return (string)this["name"];
            }
        }

        /// <summary>
        /// The machine names (separated by commas) for which the Logger will be created. An empty value creates it on all machines.
        /// </summary>
        [ConfigurationProperty("machine", DefaultValue = "", IsRequired = false)]
        [Description("The machine names (separated by commas) for which this logger will be created. Leaving it empty will create it on all machines")]
        public string Machine
        {
            get
            {
                return (string)this["machine"];
            }
        }

        /// <summary>
        /// Check if the Internal Exception Logging is enabled
        /// </summary>
        [ConfigurationProperty("enableInternalExceptionLogging", DefaultValue = false, IsRequired = false)]
        [Description("true if the internal exceptionLogging is enabled; otherwise false")]
        public bool IsInternalLoggingEnabled
        {
            get
            {
                return (bool)this["isInternalLoggingEnabled"];
            }
        }

        /// <summary>
        /// Check if the Logger is enabled
        /// </summary>
        [ConfigurationProperty("isEnabled", DefaultValue = true, IsRequired = false)]
        [Description("true if the logger is enabled; otherwise false")]
        public bool IsEnabled
        {
            get
            {
                return (bool)this["isEnabled"];
            }
        }

        /// <summary>
        /// The LogLevel of the Logger
        /// </summary>
        [ConfigurationProperty("logLevel", DefaultValue = LogLevel.Debug, IsRequired = false)]
        [Description("The logLevel of the logger")]
        public LogLevel LogLevel
        {
            get
            {
                return (LogLevel)this["logLevel"];
            }
        }

        /// <summary>
        /// Categories to include (leave blank for all)
        /// </summary>
        [ConfigurationProperty("includeCategories", DefaultValue = "", IsRequired = false)]
        [Description("The categories, separated by commas, to include when logging. Leave blank to include everything.")]
        public string IncludeCategories
        {
            get
            {
                return (string)this["includeCategories"];
            }
        }

        /// <summary>
        /// Categories to exclude
        /// </summary>
        [ConfigurationProperty("excludeCategories", DefaultValue = "", IsRequired = false)]
        [Description("The categories, separated by commas, to exclude when logging.")]
        public string ExcludeCategories
        {
            get
            {
                return (string)this["excludeCategories"];
            }
        }

        /// <summary>
        /// If true, wrap the Logger in an KeepLoggingLogger.
        /// </summary>
        [ConfigurationProperty("keepLogging", DefaultValue = false, IsRequired = false)]
        [Description("if true, the logger will be wrapped in a KeepLoggingLogger")]
        public bool keepLogging
        {
            get
            {
                return (bool)this["keepLogging"];
            }
        }

        /// <summary>
        /// If true, wrap the Logger in an AsynchronousLogger.
        /// </summary>
        [ConfigurationProperty("isAsynchronous", DefaultValue = false, IsRequired = false)]
        [Description("if true, the logger will be wrapped in a AsynchronousLogger")]
        public bool IsAsynchronous
        {
            get
            {
                return (bool)this["isAsynchronous"];
            }
        }

        /// <summary>
        /// The FormatString for the Logger
        /// </summary>
        [ConfigurationProperty("formatString", DefaultValue = "", IsRequired = false)]
        [Description("The format string of the logger. If blank, it will use the format string of the enclosing section (the CollectionOfLoggers).")]
        public virtual string FormatString
        {
            get
            {
                return (string)this["formatString"];
            }
        }
    }
}


Asked can't count on XMLDocument.

$
0
0
<English><id>1</id><title>Day of the dead audio</title><level>Level 1</level><foder>Day of the dead lessons</foder><part>1.Original Effortless English Lessons</part></English><English><id>2</id><title>Day of the dead vocab</title><level>Level 1</level><foder>Day of the dead lessons</foder><part>1.Original Effortless English Lessons</part></English><English><id>1</id><title>Visit To San Francisco Part 2 MS</title><level>Level 4</level><foder>Visit To San Francisco Part 1</foder><part>2.Learn Real English</part></English><English><id>1</id><title>Visit To San Francisco Part 2 MS</title><level>Level 4</level><foder>Visit To San Francisco Part 1</foder><part>2.Learn Real English</part></English>



public object query_list_info()
        {
            XDocument xml = XDocument.Load(@"XMLEffort.xml");
            List<Data> data = (from q in xml.Elements("effort").Elements("English")
                               group q by q.Element("part").Value into g
                               select new Data
                               {

                                   count_session=g.Elements("part").FirstOrDefault().Value.Count(),
                                   count_song=g.Elements("title").FirstOrDefault().Value.Count(),

}).ToList(); return data; }


XML Error in the Setup project file with extension .InstallState

$
0
0

I recently upgraded from VS 2010 to VS 2013. I also installed the new Microsoft Visual Studio Installer that was able to compile my .vdproj ( setup project file). But there is this file in the setup project myproject.InstallState. The install program complains that the "Soap: Envelope XML element is missing a type attribute" I did not generate this file manually and I don't know how to regenerate it. But here is the entire file . Can some one figure out the error?

<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><a1:Hashtable id="ref-1" xmlns:a1="http://schemas.microsoft.com/clr/ns/System.Collections"><LoadFactor>0.72</LoadFactor><Version>2</Version><Comparer xsi:null="1"/><HashCodeProvider xsi:null="1"/><HashSize>11</HashSize><Keys href="#ref-2"/><Values href="#ref-3"/></a1:Hashtable><SOAP-ENC:Array id="ref-2" SOAP-ENC:arrayType="xsd:anyType[2]"><item id="ref-4" xsi:type="SOAP-ENC:string">_reserved_nestedSavedStates</item><item id="ref-5" xsi:type="SOAP-ENC:string">_reserved_lastInstallerAttempted</item></SOAP-ENC:Array><SOAP-ENC:Array id="ref-3" SOAP-ENC:arrayType="xsd:anyType[2]"><item href="#ref-6"/><item xsi:type="xsd:int">0</item></SOAP-ENC:Array><SOAP-ENC:Array id="ref-6" SOAP-ENC:arrayType="a1:IDictionary[1]" xmlns:a1="http://schemas.microsoft.com/clr/ns/System.Collections"><item href="#ref-7"/></SOAP-ENC:Array><a1:Hashtable id="ref-7" xmlns:a1="http://schemas.microsoft.com/clr/ns/System.Collections"><LoadFactor>0.72</LoadFactor><Version>2</Version><Comparer xsi:null="1"/><HashCodeProvider xsi:null="1"/><HashSize>11</HashSize><Keys href="#ref-8"/><Values href="#ref-9"/></a1:Hashtable><SOAP-ENC:Array id="ref-8" SOAP-ENC:arrayType="xsd:anyType[2]"><item href="#ref-4"/><item href="#ref-5"/></SOAP-ENC:Array><SOAP-ENC:Array id="ref-9" SOAP-ENC:arrayType="xsd:anyType[2]"><item href="#ref-10"/><item xsi:type="xsd:int">-1</item></SOAP-ENC:Array><SOAP-ENC:Array id="ref-10" SOAP-ENC:arrayType="a1:IDictionary[0]" xmlns:a1="http://schemas.microsoft.com/clr/ns/System.Collections"></SOAP-ENC:Array></SOAP-ENV:Body></SOAP-ENV:Envelope>


Issue with C# code generation for an xsd using the utility xsd.exe version 4.0.3

$
0
0

We are trying to create a C# class file from an xsd using the xsd.exe utility version 4.0.3 .

The  xsd nested elements are not getting populated ...please provide your suggestions!!

how to delete the whole XMLNode

$
0
0

hi

   my code is like that:  

XmlNodeList nodeList = root.SelectNodes("//item[@key='" + Key + "']");              
                if (nodeList.Count > 1)
                {
                    foreach (XmlNode item in nodeList)
                    {                        
                        item.RemoveAll();
                    }
                } 

     then i found the xml file like

  <item />
  <item />

     may i ask is it possible to delete all,inclduing   <item />?

    thank u very much

best regards

martin

   

Given XElement item how can I find its XPath

$
0
0

Hi there, I am facing this simple problem I cannot immediately crack. I search thru an xml file, find a few nodes I need and collect the objects (XElement(s)). How can I get the XPath to each of them? And I mean the expression string.

 

I search for the nodes by a value of one attribute ( "ID" ) that each node has. They are unique and are used for identification. The nodes themselves all have identical names: "Item," except for the root node which is "Items" thus I cannot use them for search to determine the path.

 

Thanks.

Different behaviour of XSD validation on Windows8

$
0
0

Good morning,

I found that XSD validation on Windows8 (probably because of different MSXML6 version?) behaves differently from previous OSes with respect to fixed attributes defined in XSD.

If you define an attribute with a fixed value in XSD and apply it to an XML instance, all validated XML nodes will get that attribute "auto-magically". I used this feature to give a sort of "class attributes" to XML nodes without defining them explicitly in the XML document.

1) if you add a new node of a valid type, on previous versions it will get fixed attributes automatically without doing anything. On Windows8 I have to call validateNode() everytime to apply them

2) if a validate() fails, none of the nodes of the document will get fixed attributes. On previous versions, every valid node get them even if validation has failed

Is there a reason for this? Is it a bug? Is it possible to restore previous behaviour?

Thanks

Davide

Reading XML with a Namespace via XElement

$
0
0
I'm working on an application that includes an RSS reader, and came across something I don't know how to handle.

The XML file is formed like so:
<?xml version="1.0" encoding="windows-1251"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Feed Title</title><link>http://feed.net/</link><language>en</language><description>A really cool feed</description><generator>DataLife Engine</generator><item><title>Item Title</title><guid isPermaLink="true">http://feed.net/item.html</guid><link>http://feed.net/item.html</link><description><![CDATA[<div align="center">a bunch of HTML in here</div><br /><br />]]></description><category><![CDATA[Category Name]]></category><dc:creator>Creator Name</dc:creator><pubDate>Tue, 02 Mar 2010 17:34:33 +0300</pubDate></item></channel></rss>
The problem I have is this:

When I attempt to read the creator element with
NewItem.Creator = thisItem.Element("creator").Value;
I get an error, because thisItem.Element("creator") is null.  How can I correctly resolve this element?  I've tried
NewItem.Creator = thisItem.Element("dc:creator").Value;
but that gives me an error saying that ":" is not a valid character in an element name. 

I'm guessing I'll have to parse the namespace and prepend it to the element name, but how would I do that?

Thanks!

Gabe

XSLT to remove lines in XML

$
0
0

When the count is zero, i want to remove only the zero-count lines and copy all other lines as is. For example

XML input file

<Store id = "34343>5</Store>

<Store id="12345">0</Store>


Output should only contain <Store id = "34343>5</Store>

Can some one please help. Thank You

How to load a subset of data from DataGridView back to XmlDocument

$
0
0

I have an xml file that I want users to be able to edit via a DataGridView.  I am loading just one of the many nodes from the xml file into the DataGridView (including it's child nodes). Can someone help me get the user edited subset of data back into the XmlDocument so I can then save it? Here is the sample xml:

<?xml version="1.0" encoding="utf-8"?><Customer name="TestCustomer" location="Durham, NH"><Device DeviceName="MyDevice1"><DeviceOption FeatureName="Feature Name 1" Value="False" Notes="Notes about this feature 1"></DeviceOption><DeviceOption FeatureName="Feature Name 2" Value="False" Notes="Notes about this feature 2"></DeviceOption><DeviceOption FeatureName="Feature Name 3" Value="27" Notes="Notes about this feature 3"></DeviceOption><DeviceOption FeatureName="Feature Name 4" Value="True" Notes="Notes about this feature 4"></DeviceOption></Device><Device DeviceName="MyDevice2"><DeviceOption FeatureName="Feature Name 1" Value="False" Notes="Something about this feature 1"></DeviceOption><DeviceOption FeatureName="Feature Name 2" Value="True" Notes="Something about this feature 2"></DeviceOption><DeviceOption FeatureName="Feature Name 3" Value="18" Notes="Something about this feature 3"></DeviceOption><DeviceOption FeatureName="Feature Name 4" Value="True" Notes="Something about this feature 4"></DeviceOption></Device></Customer>

Once I find the Device XmlNode I'm looking for I load the DataGridView with the child nodes like this:

private void FillGridWithOEDeviceOptions(XmlNode node1) { XmlReader xr = new XmlNodeReader(node1); DataSet ds = new DataSet(); ds.ReadXml(xr); dataGridView1.DataSource = ds.Tables["DeviceOption"];

}

Can someone help me get the user edited subset of data back into the XmlDocument so I can then save it?

Thanks in advance.


MS Powerpoint

$
0
0
I got an Idea for MS Powerpoint and need to post it to appropriate Microsoft site, could some one help with the link.

To Serialize XML document from XSD generated class [Continuity care of document]

$
0
0

Hi All,

I have some problem in my project and I need your help and guidance.

Now we have successfully generated the Object Class from CCD schema file. [ccd.xsd]

We have values in our database table, which we want on our CCD/CCR XML file 

We want to create a read/write CCR and CCD XML file.

So can you help to generate the XML file?

Any help would be greatly appreciated


With Regards Nishanth Suraj

Missing prefix "saml:" when Using "Microsoft.IdentityModel.Tokens.Saml2" to make SAML V2.0

$
0
0

why can SAML2 produce a SAML where it use the prefix "SAML:" Like in this exemple:

   <?xml version="1.0" encoding="utf-8"?>
   <saml:Assertion ID="_51bc8a37-0b6d-4e13-81e9-e1778a9b4dd3" IssueInstant="2012-10-10T19:32:07.526Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
    <saml:Issuer>someidentifier</Issuer>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
     <ds:SignedInfo>
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
      <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
      <ds:Reference URI="#_51bc8a37-0b6d-4e13-81e9-e1778a9b4dd3">
       <ds:Transforms>
        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
       </ds:Transforms>
       <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
       <ds:DigestValue>N3UrIhpT+EXn+CeMiaq98v4n6vWw=</ds:DigestValue>
      </ds:Reference>
     </ds:SignedInfo>
<ds:SignatureValue>ACDCBN55g2FTo82jWjfN67BQB7XyC1UxUIqr6iAGfu85O2P7WCkqDxPhsaveOOVkNgz1r4KkSEAdFdv5sh4xCumooUVAiQXYFMgGz6QSNjdsxUurrmetyrDLQOtU2phuAykY9bF4kNYuYBgvDygCq6gbv8DR+M83WbKFMHRy7nYkrHZg0DJw56aiHnZvZQr/VyIsSvxGU7ra9ED4Tbe26oWte8ysb71yAZKqcEzzFKZU1BmMoApwJU3DLVqHo5r335ayPYxcsvm3LJ3vIDx+ql3tEKFSlt2OLBYSMlhCGYbyxMwAmzWzgv53zx1DiXrBxsSFzrbqk7y4PNx2eE0NciA==</ds:SignatureValue>
     <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
      <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
       <o:KeyIdentifier ValueType="kdkT3iOnlm4C8J3oa4/KPHOyqngc=</o:KeyIdentifier">http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1">kdkT3iOnlm4C8J3oa4/KPHOyqngc=</o:KeyIdentifier>
      </o:SecurityTokenReference>
     </KeyInfo>
    </ds:Signature>
    <saml:Subject>
     <saml:NameID Format="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">12345</saml:NameID>
     <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
     </saml:SubjectConfirmation>
    </saml:Subject>
    <saml:Conditions NotBefore="2012-10-10T19:31:37.526Z" NotOnOrAfter="2012-10-10T19:32:37.526Z">
    </saml:Conditions>
    <saml:AttributeStatement>
     <saml:Attribute Name="userud">
      <saml:AttributeValue>999999</saml:AttributeValue>
     </saml:Attribute>
    </saml:AttributeStatement>
   </saml:Assertion>

 

 

but all I can produce is (where's the "SAML" prefix?):


   <?xml version="1.0" encoding="utf-8"?>
   <Assertion ID="_51bc8a37-0b6d-4e13-81e9-e1778a9b4dd3" IssueInstant="2012-10-10T19:32:07.526Z" Version="2.0" xmlns="urn:oasis:names:tc:2.0:assertion">
    <Issuer>someidentifier</Issuer>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
     <ds:SignedInfo>
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
      <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
      <ds:Reference URI="#_51bc8a37-0b6d-4e13-81e9-e1778a9b4dd3">
       <ds:Transforms>
        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
       </ds:Transforms>
       <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
       <ds:DigestValue>N3UrIhpT+EXn+CeMiaq98v4n6vWw=</ds:DigestValue>
      </ds:Reference>
     </ds:SignedInfo>
     <ds:SignatureValue>ACDCBN55g2FTo82jWjfN67BQB7XyC1UxUIqr6iAGfu85O2P7WCkqDxPhsaveOOVkNgz1r4KkSEAdFdv5sh4xCumooUVAiQXYFMgGz6QSNjdsxUurrmetyrDLQOtU2phuAykY9bF4kNYuYBgvDygCq6gbv8DR+M83WbKFMHRy7nYkrHZg0DJw56aiHnZvZQr/VyIsSvxGU7ra9ED4Tbe26oWte8ysb71yAZKqcEzzFKZU1BmMoApwJU3DLVqHo5r335ayPYxcsvm3LJ3vIDx+ql3tEKFSlt2OLBYSMlhCGYbyxMwAmzWzgv53zx1DiXrBxsSFzrbqk7y4PNx2eE0NciA==</ds:SignatureValue>
     <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
      <o:SecurityTokenReference xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
       <o:KeyIdentifier ValueType="kdkT3iOnlm4C8J3o4/KPHOyqngc=</o:KeyIdentifier">http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1">kdkT3iOnlm4C8J3o4/KPHOyqngc=</o:KeyIdentifier>
      </o:SecurityTokenReference>
     </KeyInfo>
    </ds:Signature>
    <Subject>
     <NameID Format="urn:oasis:names:tc:2.0:attrname-format:unspecified">12345</NameID>
     <SubjectConfirmation Method="urn:oasis:names:tc:2.0:cm:bearer">
     </SubjectConfirmation>
    </Subject>
    <Conditions NotBefore="2012-10-10T19:31:37.526Z" NotOnOrAfter="2012-10-10T19:32:37.526Z">
    </Conditions>
    <AttributeStatement>
     <Attribute Name="userud">
      <AttributeValue>999999</AttributeValue>
     </Attribute>
    </AttributeStatement>
   </Assertion>

 

 

 

 

 

 

 

 

 

Here is my code:


 
   Saml2NameIdentifier assertionNameIdentifier = new Saml2NameIdentifier("someidentifier");
   Saml2Assertion assertion = new Saml2Assertion(assertionNameIdentifier);
   assertion.Id = new Saml2Id(SamlAssertionID);
   assertion.IssueInstant = dtIssueInstant;
   assertion.Conditions = new Saml2Conditions();
   assertion.Conditions.NotBefore = dtNotBefore;
   assertion.Conditions.NotOnOrAfter = dtNotOnOrAfter;
   //
   // Create some SAML subject.
   assertion.Subject = new Saml2Subject();
   assertion.Subject.NameId = new Saml2NameIdentifier("12345");
   assertion.Subject.NameId.Format = new Uri("urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified");
   
   //
   // Now create the SAML statement containing one attribute and one subject.
   Saml2AttributeStatement samlAttributeStatement = new Saml2AttributeStatement();
   
   //
   // Create one SAML attribute with few values.
   Saml2Attribute attr = null;
   
   attr = new Saml2Attribute("userid");
   attr.FriendlyName = "userid";
   attr.Values.Add("999999");
   samlAttributeStatement.Attributes.Add(attr);
   
   // Append the statement to the SAML assertion.
   assertion.Statements.Add(samlAttributeStatement);
   
   
   /**************************************************************
   * END createSamlAssertion()
   **************************************************************/
   
   //
   // Signing credentials are consisted
   // of private key in the certificate (see above),
   // the signature algorithm, security algortihm and key identifier.
   assertion.SigningCredentials =
   new SigningCredentials(signingKey, SecurityAlgorithms.RsaSha1Signature,
                   SecurityAlgorithms.Sha1Digest,
                   new SecurityKeyIdentifier(new X509ThumbprintKeyIdentifierClause(SigningCert)));
   
   
   
   // Finally create the SamlSecurityToken from the assertion
   Saml2SecurityToken samlToken = new Saml2SecurityToken(assertion);
   
   
   var tokenhandler = new Microsoft.IdentityModel.Tokens.Saml2.Saml2SecurityTokenHandler();
   
   var settings = new XmlWriterSettings();
   settings.Indent = false;
   settings.Encoding = Encoding.UTF8;
   
   using (var xWriter = XmlWriter.Create(@"c:\saml2.xml", settings))
   {
      
       Debug.WriteLine(xWriter.LookupPrefix("urn:oasis:names:tc:SAML:2.0:assertion"));
       tokenhandler.WriteToken(xWriter, samlToken);
       xWriter.Flush();
       xWriter.Close();
   }

 

No value given for one or more required parameters..'

$
0
0

I am new to XML coding. we have some builds which use the xml files and i have no idea why its failing. 

review_netnew_logs:
  [echo] 1) while: 'Executing Merged SQL Files...'
  [echo] @line: 38, found: 'Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : No value given for one or more required parameters..'
  [echo] Completed "F:\Build_Results\PreBVT_40\0400_999_Package\PRODPATH\Scripts"\03Code - 11:31:01.44
  [echo]
  [echo] Net New had porting errors:
  [echo] 1) while: 'Executing Merged SQL Files...'
  [echo] @line: 38, found: 'Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : No value given for one or more required parameters..'
  [echo] Completed "F:\Build_Results\PreBVT_40\0400_999_Package\PRODPATH\Scripts"\03Code - 11:31:01.44
  [echo]
 
 BUILD FAILED
 F:\Accurev_Viewstore\SEDA-CI-CODEBASE\SRN_DBArch_Dev\ContinuousIntegration\CI\PreBVT_40\Build.xml:172: The following error occurred while executing this line:
 F:\Accurev_Viewstore\SEDA-CI-CODEBASE\SRN_DBArch_Dev\ContinuousIntegration\CI\Common\build-validate.xml:589: The following error occurred while executing this line:
 F:\Accurev_Viewstore\SEDA-CI-CODEBASE\SRN_DBArch_Dev\ContinuousIntegration\CI\Common\build-validate.xml:540: The following error occurred while executing this line:
 F:\Accurev_Viewstore\SEDA-CI-CODEBASE\SRN_DBArch_Dev\ContinuousIntegration\CI\Common\build-macros.xml:244: DB errors encountered!
 

I looked into the build-validate.xml file. I tried to search on netnewscriptingtracepath in file but its not mentioned anywhere else except code below.

  <target name="review_netnew_logs">

    <check_db_log_for_errors
       logfilepath="${netnewscriptingtracepath}"
       looptype="Net New"/>

    <!--<zip destfile="${workspacepath}\logs_netnew.zip"
      basedir="${netnewscriptingtracepath}"
      />

    <delete dir="${netnewscriptingtracepath}" failonerror="false"/>-->
  </target>

  <target name="review_preport_logs">

    <check_db_log_for_errors
       logfilepath="${preportingscriptingtracepath}"
       looptype="Preport"/>


display data from database XMLformat using wcf service?

$
0
0
I am getting data from database using wcf service,

At the time of displaying data in browser not displaying correct format

this is my code

[DataContract]
    public class StopUpdate
    {
       [DataMember]
        public string STOP_SEQUENCE { get; set; }
        [DataMember]
        public string STOPTYPE { get; set; }
        [DataMember]
        public string DUE_TIMEZONE { get; set; }
        [DataMember]
        public string DUE { get; set; }
        [DataMember]
        public string ENDDUE { get; set; }
        [DataMember]
        public string ACTUALARRIVAL_TIMEZONE { get; set; }
        [DataMember]
        public string ACTUALARRIVAL { get; set; }
        [DataMember]
        public string ACTUALDEPART_TIMEZONE { get; set; }
        [DataMember]
        public string ACTUALDEPART { get; set; }
    }
    [DataContract]
    public class CompanyDefinedField
    {

        [DataMember]
        public string TRIPNUM { get; set; }
        [DataMember]
        public string DLULOAD { get; set; }
        [DataMember]
        public string ND { get; set; }
        [DataMember]
        public string LOADING_CARRIER { get; set; }
    }

    /////////////////
    [DataContract]
    public class Status
    {
        [DataMember]
       public string ROUP_ID {get;set;}
       [DataMember]
       public System.DateTime PROCESSED_DATE{get;set;}
           [DataMember]
       public string PST_STATUS_TYPE{get;set;}
           [DataMember]
       public int LOADID{get;set;}
           [DataMember]
       public string SHIPPER_REF{get;set;}
           [DataMember]
       public string TENDERID{get;set;}
           [DataMember]
       public string LOADREFERENCE{get;set;}
           [DataMember]
       public string TRAILERNUM{get;set;}
           [DataMember]
       public string DRIVERNAME{get;set;}
           [DataMember]
       public string VEHICLENUMBER{get;set;}
           [DataMember]
       public string FORCECLOSE{get;set;}
           [DataMember]
       public string ENROUTE{get;set;}
           [DataMember]
       public string WSHOLDSTATUS{get;set;}
           [DataMember]
       public string PRIORITY{get;set;}
           [DataMember]
       public string COMMENTS{get;set;}
           [DataMember]
       public string SHIPPINGSTATUSCODESET{get;set;}
           [DataMember]
       public string TRIPNUM{get;set;}
           [DataMember]
       public string DLULOAD{get;set;}
           [DataMember]
       public string ND{get;set;}
           [DataMember]
       public string LOADING_CARRIER{get;set;}

        [DataMember]
        public List<StopUpdate> stopUpdates;

        [DataMember]
        public List<CompanyDefinedField> CompanyDefinedFields;
    }
Interface methos:
[WebGet(ResponseFormat = WebMessageFormat.Xml)]
        [OperationContract]
        List<Status> Allstatus(int loadid);

Implementation:

public List<Status> AllLoadstatus(int loadid)

        {



            List<Status> lists = new List<Status>();



            /

            SqlConnection con = new SqlConnection(@"Data Source=ASHDEVBTS-1;Initial Catalog=Sampath;Integrated Security=True");

            con.Open();

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = con;

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Clear();

            cmd.CommandText = "Select_sta";

            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())

            {

                Status sh = new Status();

                sh.LEAN_LOAD_ID = Convert.ToInt32(dr["LEAN_LOAD_ID"]);

                sh.PST_STATUS_TYPE = Convert.ToString(dr["PST_STATUS_TYPE"]);

                sh.TRIPNUM = Convert.ToString(dr["TRIPNUM"]);

                sh.DLULOAD = Convert.ToString(dr["DLULOAD"]);



                sh.ND = Convert.ToString(dr["ND"]);

                sh.STOP_SEQUENCE = Convert.ToString(dr["STOP_SEQUENCE"]);

                sh.CMP_ID = Convert.ToString(dr["CMP_ID"]);

                sh.DUE_DATE_START = Convert.ToDateTime(dr["DUE_DATE_START"]);

                sh.DUE_DATE_END = Convert.ToDateTime(dr["DUE_DATE_END"]);

                sh.PLAN_DEST_DRIVER_ID = Convert.ToString(dr["PLAN_DEST_DRIVER_ID"]);

                sh.PLAN_DEST_TRL_DISPLAY = Convert.ToString(dr["PLAN_DEST_TRL_DISPLAY"]);

var data = new Status(){LoadID=sp.LoadID,,

                                        stopUpdates = new List<StopUpdate>{new StopUpdate(){STOP_SEQUENCE=st.STOP_SEQUENCE,STOPTYPE=st.STOPTYPE,DUE_TIMEZONE=st.DUE_TIMEZONE,

                                       DUE=st.DUE,ENDDUE=st.ENDDUE,ACTUALARRIVAL_TIMEZONE=st.ACTUALARRIVAL_TIMEZONE,ACTUALARRIVAL=st.ACTUALARRIVAL,

                                        ACTUALDEPART_TIMEZONE=st.ACTUALDEPART_TIMEZONE,ACTUALDEPART=st.ACTUALDEPART}

                    }

                };



                lists.Add(data);

            }

            return lists.ToList();

        }


I am running getting output like this code,i am getting output like this,matching one Loadid value

<?xml version="1.0"?>

-<ArrayOfStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LoadPlan">


-<Status><LOADID>36546186</LOADID><SHIPPER_REF>AFAR </SHIPPER_REF>


    -<StopUpdate><ACTUALDEPART>Sales<ACTUALDEPART/><ACTUALDEPART_TIMEZONE>12-03-14<ACTUALDEPART_TIMEZONE/><STOPTYPE>P</STOPTYPE><STOP_SEQUENCE>1</STOP_SEQUENCE></StopUpdate></stopUpdates></Status>
in my table loadid same value in two rows,in that situation,i want to display data like this,
<?xml version="1.0"?>

-<ArrayOfStatus xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/LoadPlan">


-<Status><LOADID>36546186</LOADID><SHIPPER_REF>AFAR </SHIPPER_REF>


    -<StopUpdate><ACTUALDEPART>Sales<ACTUALDEPART/><ACTUALDEPART_TIMEZONE>12-03-14<ACTUALDEPART_TIMEZONE/><STOPTYPE>P</STOPTYPE><STOP_SEQUENCE>1</STOP_SEQUENCE></StopUpdate>
- <StopUpdate><ACTUALDEPART>dept<ACTUALDEPART/><ACTUALDEPART_TIMEZONE>11-07-14<ACTUALDEPART_TIMEZONE/><STOPTYPE>d</STOPTYPE><STOP_SEQUENCE>2</STOP_SEQUENCE></StopUpdate></stopUpdates></Status>



The condition how many times execute based on LoadId that many times get values and display

in

StopUpdate vales
can you please give me the idea about that one


anilbabu

Viewing all 935 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>