Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
G

GrgBalden

@GrgBalden
About
Posts
13
Topics
5
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Reading & Modifying XML Data in C#
    G GrgBalden

    Thank you kindly!!! Will give this a go tommorow!

    C# csharp testing tools xml help

  • Reading & Modifying XML Data in C#
    G GrgBalden

    Hi can anyone else help with this, I'm somewhat limited to c#2 (using VS2005)??

    C# csharp testing tools xml help

  • Reading & Modifying XML Data in C#
    G GrgBalden

    Thanks for Info! I don't suppose you have the c# code?

    C# csharp testing tools xml help

  • Reading & Modifying XML Data in C#
    G GrgBalden

    Hi Guys Hope you can help. I'm writing a program to do a record count within an XML file The XML file is structured as per below:

    <WEBRequest>
    <Request>
    <BlockA>
    <REC>
    <CustomerNumber></CustomerNumber>
    <FirstName></FirstName>
    <LastName></LastName>
    <Email></Email>
    </REC>
    </BlockA>
    <BlockB>
    <REC>
    <FirstName></FirstName>
    <LastName></LastName>
    <OrderDetail></OrderDetail>
    <PartType></PartType>
    </REC>
    <REC>
    <FirstName></FirstName>
    <LastName></LastName>
    <OrderDetail></OrderDetail>
    <PartType></PartType>
    </REC>
    <REC>
    <FirstName></FirstName>
    <LastName></LastName>
    <OrderDetail></OrderDetail>
    <PartType></PartType>
    </REC>
    </BlockB>
    <BlockC>
    ....
    ....
    ....
    ....
    </BlockC>
    ....
    ....
    ....
    </Request>

    What I need to do is count and output number of <REC>'s for each <Block> element and output to a cell within excel (Excel Automation is working). E.g. BlockA = 1 REC BlockB = 3 REC . . . BlockM = 32 REC I have the excel automated correctly, however, I'm afraid that my inexperience with XML is quite telling, so I dont have a clear idea on how to do the record count. Thanks in advance!!! Grg!

    C# csharp testing tools xml help

  • Dynamic IP & Writing to the Webspace
    G GrgBalden

    Thanks Walt, Yeah, I've used this previously. I want to try and steer clear of all in one solutions. Anyone with any thoughts on writing IP to a website?

    Web Development help tools tutorial question

  • Dynamic IP & Writing to the Webspace
    G GrgBalden

    Hi Guys, I'm trying to remote desktop onto my PC at home, however since I have ADSL and my ISP doesnt support static IP addresses, I end up having to check my IP address before I head into work. Problem is my line is pretty rubbish, and the connection gets dropped every 4-6 hours. So i get maybe 4-6 hours out of it, then no longer have access to my home desktop. Thinking on it, the easiest solution (Barring a Static IP) is to run a script that will automatically write my IP to my website (hosted externally). Does anyone have any ideas on how to do this? Solutionising is welcome? Thanks for your help, Grg

    Web Development help tools tutorial question

  • Excel + C#
    G GrgBalden

    Hi all, I've been given source code for a program that created a form post from values within an excel document, however I keep getting the following errors: Property, indexer, or event 'Value' is not supported by the language; try directly calling accessor methods 'Microsoft.Office.Interop.Excel.Range.get_Value(object)' or 'Microsoft.Office.Interop.Excel.Range.set_Value(object, object)' I've had a root through the MSDN site, and cant seem to work out whats wrong:

    private void btnBatchExecute_Click(object sender, System.EventArgs e)
    {

            Excel.Application xlApp;
    		Excel.Workbook xlWorkbook;
    		Excel.Worksheet xlWorkSheet;
    		Excel.Range xlRange;
    
    		string method;
    		string postString;
    		string\[\] values;
    		string returnString;
    
    		XmlDocument xDoc = new XmlDocument();
    		
    		try
    		{
    			//Start Excel and get Application object.
    			xlApp = new Excel.ApplicationClass();
    			xlApp.Visible = true;
    
                string thisFileName = txtFileName.Text;
    
                xlWorkbook = xlApp.Workbooks.Open(thisFileName,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing);
    
                xlWorkSheet = (Excel.Worksheet)xlWorkbook.ActiveSheet;
    
    			
    			//int i = 5;
    			for(int i = 5;;i++)
    			{
    				xlRange = xlWorkSheet.get\_Range(xlWorkSheet.Cells\[i,2\],xlWorkSheet.Cells\[i,52\]);
    
    				values = ConvertToStringArray((System.Array)xlRange.Cells.Value);
    
    				if(values\[0\]=="") break;
    
    				postString = "ESERIES\_FORM\_ID=AUTHENTICATE\_3&CTRL\_TYPEINDICATOR=C&CTRL\_SEARCHCONSENT=Y&CTRL\_CHANNEL=I&CTRL\_CALLTYPE=I";
    				// Main App Name
    				postString+="&NAME\_TITLE="+values\[0\];
    				postString+="&NAME\_FORENAME="+values\[1\];
    				postString+="&NAME\_INITIALS="+values\[2\];
    				postString+="&NAME\_SURNAME="+values\[3\];
    				postString+="&NAME\_SUFFIX="+values\[4\];
    				postString+="&NAME\_DATEOFBIRTH\_DD="+("0"+values\[5\]).Substring(("0"+values\[5\]).Length-2);
    				postString+="&NAME\_DATEOFBIRTH\_MM="+("0"+values\[6\]).Substring(("0"+values\[6\]).Length-2);
    				postString+="&NAME\_DATEOFBIRTH\_CCYY="+values\[7\];
    

    // postString+="&NAME_DATEOFBIRTH="+values[7]+("0"+values[6]).Substring(("0"+values[6]).Length-2)+("0"+values[5]).Substring(("0"+values[5]).Length-2);

    				// Alias - need to check if title supplied fi
    
    C# csharp com data-structures

  • Function to Find and Replace in C#
    G GrgBalden

    Thanks for the pointer, I was hoping that someone would know how to change a file extention by changing the file extention using a string? Any more ideas?

    C# csharp xml question

  • Function to Find and Replace in C#
    G GrgBalden

    Hi, Thanks for the help I've added your suggestion and it seems to be working; I'm now trying to change the file extention of the files in the directory from .txt to .xml The text files already have the xml, i just need to change the file extention? Any ideas? I tried to impliment an Ext Changer class (last in the list) but doesnt seem to work? Any provide any sample code? Program.CS

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    namespace XMLReformat
    {
    class Program
    {
    static void Main(string[] args)
    {

            //Console.WriteLine("Please Enter the directory of XML Documents:\\n");
            //string userDir = Console.ReadLine();
    
            string userDir = "C:\\\\xmlreformat";
    
            try
            {
                string\[\] filePaths = Directory.GetFiles(userDir);
                foreach (string i in filePaths)
                {
                    // Call reformat operation
    
                    Reformat.Replace(i);
                    //ExtChanger.WriteFileName(i, userDir);
                   
    
                }
                Console.WriteLine("Operation Succeeded \\n \\n Press Any Key to Exit");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Directory Not Found:" + e.Message);
                Console.WriteLine("\\n \\n Press Any Key to Exit");
                Console.ReadKey();
            }
    
            
    
        }
    }
    

    }

    Reformat.cs

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    namespace XMLReformat
    {
    class Reformat
    {

        public static void Replace(string FName)
        {
            StreamReader File = new StreamReader(FName); // create new streamreader
            
            string fileContent = File.ReadToEnd(); // create new string, read file into string
            File.Close();
    
    
            StreamWriter NewFile = new StreamWriter(FName); // create new stream writer
    
            string fileContentCopy = fileContent;
    
            string istring1 = "&gt;";
            string ostring1 = ">";
    
            string istring2 = "&lt;";
            string ostring2 = "<";
    
            fileContentCopy = fileContentCopy.Replace(istring1, ostring1);
            fileContentCopy = fileContentCopy.Replace(istring2, ostring2);
    
    
            fileContent = fileContentCopy;
    
            N
    
    C# csharp xml question

  • Function to Find and Replace in C#
    G GrgBalden

    Hi All, I've been putting together a short program too automatically to find and replace a string within all files of a directory. For my first set of replacements I want to replace: • “>” with “>” • “<” with “<” Program.CS

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    namespace XMLReformat
    {
    class Program
    {
    static void Main(string[] args)
    {

            //Console.WriteLine("Please Enter the directory of XML Documents:\\n");
            //string userDir = Console.ReadLine();
    
            string userDir = "C:\\\\xmlreformat";
    
            try
            {
                string\[\] filePaths = Directory.GetFiles(userDir);
                foreach (string i in filePaths)
                {
                    // Call reformat operation
    
                    Reformat.Replace(i);
    
                }
                Console.WriteLine("Operation Succeeded \\n \\n Press Any Key to Exit");
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine("Directory Not Found:" + e.Message);
                Console.WriteLine("\\n \\n Press Any Key to Exit");
                Console.ReadKey();
            }
    
            
    
        }
    }
    

    }

    Reformat.CS

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.IO;

    namespace XMLReformat
    {
    class Reformat
    {

        public static void Replace(string FName)
        {
            StreamReader File = new StreamReader(FName); // create new streamreader
            
            string fileContent = File.ReadToEnd(); // create new string, read file into string
            File.Close();
    
    
            StreamWriter NewFile = new StreamWriter(FName); // create new stream writer
    
            string fileContentCopy = fileContent;
    
            string istring1 = "&gt;";
            string ostring1 = ">";
    
            string istring2 = "&lt;";
            string ostring2 = "<";
    
            fileContentCopy.Replace(istring1, ostring1);
            fileContentCopy.Replace(istring2, ostring2);
    
    
            fileContent = fileContentCopy;
    
            NewFile.Write(fileContent);
    
    
        }
    
    
    }
    

    }

    However when I run the program it doesnt seem to work at all. Any ideas? Thanks, George

    C# csharp xml question

  • Urgent Help With Serialization needed
    G GrgBalden

    Hi Henry, thanks for your help, I updated the project with your comments but now I'm getting a HTTP 500 error when i Invoke the web service, the full code listing is below: order.aspx.cs

    using System;
    using System.IO;
    using System.Xml.Serialization;
    using System.Data;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using ExampleforCodeProject;

    namespace ExampleforCodeProject
    {

    \[WebService(Namespace = "http://MyXmlTest/")\]
    \[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1\_1)\]
    \[ToolboxItem(false)\]
    public class Order : System.Web.Services.WebService
    {
    
        \[WebMethod\]
        public NewOrder SerialiseOrder()
        {
            NewOrder order1 = new NewOrder();
    
    
    
            order1.AccountGroup = "11";
            order1.AccountNumber = "878";
            order1.Card.CardFirstName = "George";
            order1.Card.CardLastName = "Balden";
            order1.Card.CardNumber = "872947924793274";
    
    
    
            Stream stream = File.Open("C:\\\\test\\\\NewSoap.xml", FileMode.Create); //Create a file
            XmlSerializer sf = new XmlSerializer(typeof(NewOrder)); //
            sf.Serialize(stream, order1); //serialise
            stream.Close();
            return order1;
        }
    }
    

    }

    and the Order class (NewOrder.cs):

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using ExampleforCodeProject;

    namespace ExampleforCodeProject
    {
    [Serializable]
    public class NewOrder
    {

        public NewOrder() { } //constructor
        ~NewOrder() { } //Destructor
    
        private string accountGroupfield;
        private string accountNumberfield;
    
        public string AccountGroup
        {
            get
            {
                return accountGroupfield;
            }
            set
            {
                accountGroupfield = value;
            }
        }
    
        public string AccountNumber
        {
            get
            {
                return accountNumberfield;
            }
            set
            {
                accountNumberfield = value;
            }
        }
    
        public CardDetail Card;
    
        \[Serializable\]
        public class CardDetail
    
    C# csharp algorithms xml json help

  • Urgent Help With Serialization needed
    G GrgBalden

    Could you provide some sample code of how i do that, and where i put the code? would it be similar to:

    public CardDetail MyCardDetail;

    before i declare the class? Thanks in advance! George

    C# csharp algorithms xml json help

  • Urgent Help With Serialization needed
    G GrgBalden

    Hi, I'm new to the world of .Net and C#. I need some help with serialization: I'm trying to serialize an object to an XML file, this object has a nested class which I also want to serialize:

    [Serializable]
    public class NewOrder
    {
    //constructor
    public NewOrder()
    {
    }

        //Destructor
        ~NewOrder()
        {
        }
        private string accountGroupfield;
        private string accountNumberfield;
    
        public string AccountGroup
        {
            get
            {
                return accountGroupfield;
            }
            set
            {
                accountGroupfield = value;
            }
        }
    
        
        public string AccountNumber
        {
            get
            {
                return accountNumberfield;
            }
            set
            {
                accountNumberfield = value;
            }
        }
    

    [Serializable]
    public class CardDetail
    {

            private string cardFirstNamefield;
            private string cardLastNamefield;
            private string cardNumberfield;
    
            public string CardFirstName
            {
                get
                {
                    return cardFirstNamefield;
                }
                set
                {
                    cardFirstNamefield = value;
                }
            }
    
            
           
            public string CardLastName
            {
                get
                {
                    return cardLastNamefield;
                }
                set
                {
                    cardLastNamefield = value;
                }
            }
    
            public string CardNumber
            {
                get
                {
                    return cardNumberfield;
                }
                set
                {
                    cardNumberfield = value;
                }
            }
    

    }

    I have a function to serialize the object but all I get in the Xml file is:

    <?xml version="1.0"?>
    <NewOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <AccountGroup>100</AccountGroup>
    <AccountNumber>66302</AccountNumber>
    </NewOrder>

    I've been searching around the internet for days now, but I still havent managed to get the nested class output

    C# csharp algorithms xml json help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups