|
Hi, since it is a simple requirement, I have placed a simple solution
Try this..
//////////////////////////////////////////
using System;
using System.Xml;
namespace ConsoleApplication1
{
/* c:\pk.xml
<people>
<person>
<lname> Washington
<fname> George
<person>
<lname> Lincoln
<fname> Abraham
*/
class XmlTest
{
XmlDocument doc;//
public XmlTest()
{
doc = new XmlDocument();
doc.Load("c:\\pk.xml"); // put your file path
}
public void Run()
{
while(true)
{
Console.Write("\nEnter a Name: ");
string input = Console.ReadLine();
if(input == "" || input==null)
break;
Console.WriteLine("Your FName is " + GetFName(input));
}
}
public string GetFName(string lname)
{
string ret = "Unknown" ;
XmlNodeList lnode = doc.GetElementsByTagName("Lname");
for(int i=0; i< lnode.Count; i++)
{
if(lnode.Item(i).InnerText.Trim() == lname.Trim())
{
ret = lnode.Item(i).ParentNode.LastChild.InnerText;
break;
}
}
return ret;
}
public static void Main()
{
XmlTest xmlDoc = new XmlTest();
xmlDoc.Run();
}
}
}
love2code
|
|
|
|
|
How do we parse a xml data in a string to memory (without saving it as a file ...etc.)?
In my form, i am submitting an xml file's text in a hidden field. I want to receive it as a string, and directly parse it to memory and perform DOM functions on it...
ZiggY
|
|
|
|
|
|
Hi
I am using WSE 2.0 to sign and encrypt a soap message using the x509 xcertificate. The problem is when I only sign the message it works fine but once I use encryption it gives me following error:
---------------------------------------------------------------
Microsoft.Web.Services2.Security.SecurityFault: Referenced security token could not be retrieved
at Microsoft.Web.Services2.Security.EncryptedKey.LoadXml(XmlElement element)
at Microsoft.Web.Services2.Security.EncryptedKey..ctor(XmlElement element)
at Microsoft.Web.Services2.Security.Security.LoadXml(XmlElement element)
at Microsoft.Web.Services2.Security.SecurityInputFilter.ProcessMessage(SoapEnvelope envelope)
at Microsoft.Web.Services2.Pipeline.ProcessInputMessage(SoapEnvelope envelope)
at Microsoft.Web.Services2.WebServicesExtension.BeforeDeserializeServer(SoapServerMessage message)
---------------------------------------------------------------
can any one suggest a solution to it or any workaround.
Thanks.
|
|
|
|
|
I want to know what are different types of areas are generated by XSL-FO and little description of each. Any WEB SITE(EXCEPT THAT OF W3C). Any e-book that explains...
|
|
|
|
|
Hi,
I know that the XML Serializer does not support serializing private field. So I use a public field to get/set the private field like this:
namespace TestObjectToXML.CarComponent
{
[XmlRootAttribute("Wheel", Namespace="", IsNullable=false)]
public class Wheel : IWheel
{
public string wheelSize;
private string _wheelType;
public Wheel()
{
}
public string wheelType
{
get{return this._wheelType;}
set{this._wheelType = value;}
}
public string GetWheelType()
{
return this._wheelType;
}
public void SetWheelType(string type)
{
this._wheelType = type;
}
}
}
However, if the wheel class needs to implement methods from a IWheel interface which has already some get and set method for the wheelType, is there any way to simplify this? Sometimes the interface cannot be modified and has a lot of such get and set methods.
namespace TestObjectToXML.CarComponent
{
public interface IWheel
{
string GetWheelType();
void SetWheelType(string type);
}
}
Thanks
|
|
|
|
|
hi,
I have created a webservice project and i have another project of regular type.I have to move the webservice to this regular project.In order to do that what all files should I move and what steps need to be performed.
Thanks in advance,
Satish
|
|
|
|
|
hi,
umm what do you mean "move the webservice to this regular project"? Sounds like bad design to me... maybe you could move the code to another project (class library) and reference it in your project ( and in webservice project if you will still use it). BTW what is "regular type"? Windows app or class library or.. ?
To answer your question though, all code is in file(s) with extention .asmx.cs (or maybe .asmx.vb). Only difference between web method and ordinary method is in atributes, so without them (I think) it is ordinary method like in any other project.
[edit]can't you just reference dll in /bin folder of your webservice in your project?[/edit]
Does it help?
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
Hi
has somebody an idea, a hint, a link, to find out, how to
PROGRAMATICALLY generate a sample xml file from
a xsd schema, like it is possible e.g. with XMLSpy?
I have to do this in the code (C#) for schema fragments.
What about:
- .NET xml/xsd API?
- xslt?
Thank you.
Gustavo
|
|
|
|
|
An xsd specifies what is a valid document, as you know. This includes specifying a minimum and maximum number of times a node can exist, which means that there are many possible valid documents. The other trick is that XSDs can reference other XSD's, and define types for groups of nodes. I'd be far more inclined to try and unwind this in code than in an XSLT.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Thank you for the hint. It is very helpful.
Gustavo Sierra
|
|
|
|
|
hi,
I am trying to render this xml so it looks like the way I want it but I dont; know how to do this and been trying unsucessfully the grouping without any luck. ((sorry for the duplicate)
XML:
<records>
<customer>
<id>1</id>
<name>tom</name>
<city>broon</city>
<amnt>10</amnt>
<state>sc</state>
<section>cc</section>
<recipt>ok</recipt>
</customer>
<customer>
<id>2</id>
<name>john</name>
<city>philly</city>
<amnt>50</amnt>
<state>pa</state>
<section>dd</section>
<recipt>ok</recipt>
</customer>
<customer>
<id>3</id>
<name>phil</name>
<city>dallas</city>
<amnt>100</amnt>
<state>tx</state>
<section>cc</section>
<recipt>ok</recipt>
</customer>
<customer>
<id>4</id>
<name>julian</name>
<city>menphis</city>
<amnt>133</amnt>
<state>sc</state>
<section>cc</section>
<recipt>ok</recipt>
</customer>
<customer>
<id>5</id>
<name>gloria</name>
<city>menphis</city>
<amnt>33</amnt>
<state>sc</state>
<section>dd</section>
<recipt>ok</recipt>
</customer>
</records>
and this is what I want the result to look like:
STATE: SC
SECTION: CC
ID Name Amount City Rec.PT.
1 tom 10 broon ok
4 julian 133 menphis ok
SECTION: DD
ID Name Amount City Rec.PT.
5 gloria 33 menphis ok
STATE: PA
SECTION: DD
ID Name Amount City Rec.PT.
2 John 50 philly ok
STATE: TX
SECTION: DD
ID Name Amount City Rec.PT.
3 phil 100 dallas ok
|
|
|
|
|
|
hi,
I am trying to render this xml so it looks like the way I want it but I dont; know how to do this and been trying unsucessfully the grouping without any luck.
XML:
<records>
<customer>
<id>1
<name>tom
<city>broon
<amnt>10
<state>sc
<recipt>ok
<customer>
<id>2
<name>john
<city>philly
<amnt>50
<state>pa
<recipt>ok
<customer>
<id>3
<name>phil
<city>dallas
<amnt>100
<state>tx
<recipt>ok
<customer>
<id>4
<name>julian
<city>menphis
<amnt>133
<state>sc
<recipt>ok
<customer>
<id>5
<name>gloria
<city>menphis
<amnt>33
<state>sc
<recipt>ok
and this is what I want the result to look like:
STATE: SC
SECTION: CC
ID Name Amount City Rec.PT.
1 tom 10 broon ok
4 julian 133 menphis ok
SECTION: DD
ID Name Amount City Rec.PT.
5 gloria 33 menphis ok
STATE: PA
SECTION: DD
ID Name Amount City Rec.PT.
2 John 50 philly ok
STATE: TX
SECTION: DD
ID Name Amount City Rec.PT.
3 phil 100 dallas ok
|
|
|
|
|
To display data in multiple pages using XSL.
Hi Guys i am working on pagination using XSL. I stuck in some position. After seeing the below link it works fine. but while i click on next page i couldn't access the next set of records i don't have any idea whats problem in my code. can any one suggest me where i am wrong. (<xsl:attribute name="href">_dirresult?page=<xsl:value-of select="number($Page)+1">&pagesize=<xsl:value-of
select="$PageSize">) in href i need to give "_dirresult" same thing or i need to change any thing else. please suggest me
http://www.codeproject.com/Purgatory/pagination.asp
Ram Dhage
|
|
|
|
|
Hello friends,
I need to write a xml tag, where its attribute value will be like this.
<inputparameter parametervalue="<a>s</a>" parametername="Text">
but this s giving me error, i don't want to write < >. Even i try with Cdata like this
<inputparameter parametervalue="<!CDATA[<a>s</a>]>" parametername="Text">
but still it giving me error.
Can you please help me for the same.
Sachin Gedam
(Software Engg.)
Pune India
|
|
|
|
|
|
I tried the sample code from MS
http://support.microsoft.com/default.aspx?scid=kb;en-us;312114
I got the error message at
chatcenter.Submission += new SubmissionEventHandler(callback.SubmissionCallback);
Type System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be deserialized at this security level.
it seems the delegate will not pass security check in remote object.
Does any body know why?
I am using .NET 2003 Enterprise version
Thank You
|
|
|
|
|
How can I use '<' and '>''s in the text of an xml element with out it thinking it's another element?
<pre><param name="p.table.data" value="(?n:^(?=\d)((?<month>(0?[13578])|1[02]|(0?[469]|11)(?!.31)|0?2(?(.29)(?=.29.((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))|(?!.3[01])))(?<sep>[-./])(?<day>0?[1-9]|[12]\d|3[01])\k<sep>(?<year>(1[6-9]|[2-9]\d)\d{2})(?(?=\x20\d)\x20|$))?(?<time>((0?[1-9]|1[012])(:[0-5]\d){0,2}(?i:\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$)"/></pre>
For example the "<month>" and "<sep>", how can I escape those in the xml?
/\ |_ E X E GG
|
|
|
|
|
< and >
In .NET code just use HttpUtil.HtmlEncode() . Or something like that. However I consider attributes as atomic, I wouldn't put XML (structured data) in them... Btw you say "in text" but in example use attribute - which one you really mean? If text then you can use <!CDATA[ ]> I'd prefer that over encoding, because you can more easily read you markup inside that CDATA if you need. (I can imagine it is good at least for debugging).
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
Hey guys,
I'm new to xsl, however, I literally have spent a long time trying to simply get the sum of some element nodes. For example:
<Data>
<Books>
<Book Name="Endurance" />
<Book Name="Tommorow" />
<Book Name="Easy Money" />
</Books>
</Data>
I'm trying to use <xls:number> to get the sum of the 'Book' elements.
<xsl:template match="/">
<Count>
<xsl:number count="Data/Books/Book" />
</Count>
</xsl:template>
The output is merely:
<Count>
</Count>
Does anyone know why the count="PATTERN" isnt working?
-- modified at 16:18 Thursday 30th March, 2006
|
|
|
|
|
Well,
I found it! Here is the solution if anyone is interested:
<xsl:template match="/">
<Count>
<xsl:apply-templates />
</Count>
</xsl:template>
<xsl:template match="Data/Books">
<xsl:value-of select="count(Book)" />
</xsl:template>
CHEERS!
And I hope it helps someone else.
-- modified at 16:18 Thursday 30th March, 2006
|
|
|
|
|
Good Day Everyone,
Is there any way to pass parameters to xsl file? I have to pass parameters to xsl through url like:
XYZ.xsl?param1=1000
But, its showing me illegal character error.
Is there any hope?
Thanks for the help.
|
|
|
|
|
Yes, you can pass parameters, but you need to define them in your xsl file. I'm not sure if it can be done on the browser command line.
Christian Graus - Microsoft MVP - C++
|
|
|
|