Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 21st, 2008, 07:12 AM
Authorized User
 
Join Date: May 2008
Location: Pune, Maharashtra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prafullaborade
Default convert to string

public static string xmlServiceType()
            {
                string path;
                path = Convert.ToString(HttpContext.Current.Server.MapPat h("~/App_Data/xml1.xml"));
                return path;
            }
           // convert string into xml
            public static string getReportBackUp(string MailID)
            {

                XmlDocument doc = new XmlDocument();
                doc.Load(xmlServiceType());
                XmlElement newElem = doc.CreateElement("Mail");
                XmlAttribute MailTo = doc.CreateAttribute("MailTo");
                MailTo.Value = MailID;

                newElem.Attributes.Append(MailTo);
                // doc.DocumentElement.AppendChild(newElem);

                doc.DocumentElement.AppendChild(newElem);
                string s = Convert.ToString(MailID);

                doc.Save(xmlServiceType());
                //string s = newElem.ToString();
                return s;

            }
 This code is in c# which convert String to XML & write it in xml file & database.
I am fired string from TextBox. But in XML file multiple Email ID come at single line
I want 1 Email ID at 1 Line next at next line if nos od Email ID is fired
plese send me code if any one know

my xml look like this
<Mail MailTo="paborade@yahoo.co.in,prafullaborade@rediff mail.com" />
  <Mail MailTo="paborade@yahoo.co.in,prafullaborade@rediff mail.com" />
  <Mail MailTo="prafullaborade@gmail.com,patel.jay@gmail.c om" />


i want it in this format

<Mail MailTO="prafulla@gmail.com"/>
<<Mail MailTo="prafullaborade@rediffmail.com" />

even if nos of Email ID is fired at a time from textbox



 
Old May 21st, 2008, 07:30 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well you'll need to split the MailID then and loop through the resulting strings, creating a new element for each one.

/- Sam Judson : Wrox Technical Editor -/
 
Old May 29th, 2008, 08:52 AM
Authorized User
 
Join Date: May 2008
Location: Pune, Maharashtra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prafullaborade
Default

I am using COALESCE for search criteria my query is like this where
Report_Mailed_To is xml datatype

SELECT Report.tbl_Report_Info.ReportName,tbl_ReportSentDe tails.Report_ID, Report.tbl_Report_Info.ReportPath, Report.tbl_ReportSentDetails.Report_MailedBy,
                                Report.tbl_ReportSentDetails.Report_Mailed_Date FROM Report.tbl_Report_Info INNER JOIN
                                Report.tbl_ReportSentDetails ON Report.tbl_Report_Info.ReportID = Report.tbl_ReportSentDetails.Report_ID
                                where (ReportName LIKE COALESCE(null, ReportName))AND
                                (Report_Mailed_To LIKE COALESCE (null,Report_Mailed_To))




it gives me this error
Argument data type xml is invalid for argument 1 of like function.

pls tell me how to use COALESCE with xml datatype

 
Old May 29th, 2008, 08:55 AM
Authorized User
 
Join Date: May 2008
Location: Pune, Maharashtra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prafullaborade
Default

I am using COALESCE for search criteria my query is like this where
Report_Mailed_To is xml datatype

SELECT Report.tbl_Report_Info.ReportName,tbl_ReportSentDe tails.Report_ID, Report.tbl_Report_Info.ReportPath, Report.tbl_ReportSentDetails.Report_MailedBy,
                               Report.tbl_ReportSentDetails.Report_Mailed_Date FROM Report.tbl_Report_Info INNER JOIN
                               Report.tbl_ReportSentDetails ON Report.tbl_Report_Info.ReportID = Report.tbl_ReportSentDetails.Report_ID
                               where (ReportName LIKE COALESCE(null, ReportName))AND
                               (Report_Mailed_To LIKE COALESCE (null,Report_Mailed_To))




it gives me this error
Argument data type xml is invalid for argument 1 of like function.

pls tell me how to use COALESCE with xml datatype

 
Old May 29th, 2008, 09:00 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

COALESCE returns the first non-null value passed in, so COALESCE(null, X) will simply return X. Therefore your WHERE statement reads:

Code:
WHERE ReportName LIKE ReportName AND Report_Mailed_To LIKE Report_Mailed_To
which makes no sense.

Also, the LIKE docs state that match expression (i.e. the argument before the like) must be a expression of character type. XML is not a character type.

http://msdn.microsoft.com/en-us/library/ms179859.aspx

/- Sam Judson : Wrox Technical Editor -/
 
Old May 29th, 2008, 10:04 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Please - this goes for everyone - if you are asking questions on this forum that are about products rather than about the XML standards, then tell us what products you are using. I can tell this is asking about a relational database with XML extensions, but there are lots of those around.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 29th, 2008, 10:43 AM
Authorized User
 
Join Date: May 2008
Location: Pune, Maharashtra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prafullaborade
Default

I am using COALESCE for search criteria my query is like this where
Report_Mailed_To is xml datatype

SELECT Report.tbl_Report_Info.ReportName,tbl_ReportSentDe tails.Report_ID, Report.tbl_Report_Info.ReportPath, Report.tbl_ReportSentDetails.Report_MailedBy,
                               Report.tbl_ReportSentDetails.Report_Mailed_Date FROM Report.tbl_Report_Info INNER JOIN
                               Report.tbl_ReportSentDetails ON Report.tbl_Report_Info.ReportID = Report.tbl_ReportSentDetails.Report_ID
                               where (ReportName LIKE COALESCE(null, ReportName))AND
                               (Report_Mailed_To LIKE COALESCE (null,Report_Mailed_To))




it gives me this error
Argument data type xml is invalid for argument 1 of like function.

pls tell me how to use COALESCE with xml datatype

here we are searching nos of entry from database. Mailed to is 1 search criteria from three then it is shown in datagrid

 
Old May 29th, 2008, 02:59 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You've just repeated the previous post with no new information.

Please read both mine and Michael's posts again more thoroughly before responding.

/- Sam Judson : Wrox Technical Editor -/




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert a string in DateTime elena SQL Language 6 March 29th, 2006 06:59 PM
convert string to date deeptibg SQL Server DTS 1 December 22nd, 2005 08:47 PM
Convert string to datetime nkovacevic General .NET 4 April 5th, 2005 11:57 AM
convert string to integer kcheung Classic ASP Databases 1 July 28th, 2003 04:39 PM
How to convert a string in DateTime elena ADO.NET 3 July 24th, 2003 04:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.