|
Could DataSet.ReadXml() be of any use to you?
---
http://sprdsoft.cmar-net.org - We Sprd You Softly
Our site features contents and several images. All of this is very weird.
In the end, war is not about who's right, it's about who's left.
|
|
|
|
|
i got it working using XmlDocument and XPath.
Tnx!
|
|
|
|
|
i am having a XML file and i have to apply differenr stuff on two different tags means if tag1 exists then add
<tag name="1"></tag>
and if tag2 exist then <tag name="2"></tag>
I have tried using
<xsl:if test="tag1">
<tag name="1"></tag>
</xsl:if>
but its not working,plz tell me other way to do this.
Sushant Mathur
Ocwen Financial Sol. Pvt. Ltd,
Bangalore,
INDIA.
-- modified at 8:06 Wednesday 23rd November, 2005
|
|
|
|
|
this should work. Maybe the problem is somewhere else (not test the right node, not the right namespace, etc..)
alternativaly, you can replace this with a matching structure
...
...
<xsl:apply-templates>
...
...
</xsl:template>
<xsl:template match="tag1">
<tag name="1"></tag>
</xsl:template>
<xsl:template match="tag2">
<tag name="2"></tag>
</xsl:template>
Denevers
-- modified at 15:42 Saturday 10th December, 2005
|
|
|
|
|
Does anyone know of a component for .NET that will produce an XML Signature as per the W3C standards: http://www.w3.org/TR/xmldsig-core/[^]
Also, it must be able to run on the .NET Compact Framework.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I have an xml file like this:
======================= a.xml====================
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="a.xsl"?>
<cricket>
<player id="1" age="23">
<name prefix="mr">Hung</name>
<catches>250</catches>
<no_100>23</no_100>
<no_50>34</no_50>
</player>
<player id="2" age="24">
<name prefix="mr">Thanh</name>
<catches>234</catches>
<no_100>13</no_100>
<no_50>54</no_50>
</player>
<player id="3" age="25">
<name prefix="ms">Tuan</name>
<catches>432</catches>
<no_100>11</no_100>
<no_50>33</no_50>
</player>
<player id="4" age="20">
<name prefix="mr">Hoa</name>
<catches>333</catches>
<no_100>50</no_100>
<no_50>20</no_50>
</player>
<player id="5" age="21">
<name prefix="ms">Dzuy</name>
<catches>32</catches>
<no_100>34</no_100>
<no_50>26</no_50>
</player>
</cricket>
=================================================
and an xsl to display this xml file like this:
========================== a.xsl =====================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<title>Test</title>
</head>
<body>
<table>
<tr>
<th>Player</th>
<th>No. of 50's</th>
<th>No. of 100's</th>
<th>No. of catches</th>
</tr>
<xsl:for-each select="cricket/player" order-by="name">
<tr>
<td><xsl:value-of select="name" /></td>
<td><xsl:value-of select="no_50" /></td>
<td><xsl:value-of select="no_100" /></td>
<td><xsl:value-of select="catches" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
=======================================================
The output will be like this:
Player 50's 100's Catches
Dzuy 26 34 32
Hoa 20 50 333
Hung 34 23 250
Thanh 54 13 234
Tuan 33 11 432
Now I would like to display the information of players include the id of them, like this:
ID Player 50's 100's Catches
1 Dzuy 26 34 32
2 Hoa 20 50 333
3 Hung 34 23 250
4 Thanh 54 13 234
5 Tuan 33 11 432
but I dont know how to read the attributes from player element. Any suggestion?
If I want to sort or use if statement depend on attribute (age>23 or id must be under 4 ect...), how to do that?
And how can I read attributes of elements that is read inside for-each statement, for example, attribute prefix of name element
If I want to show total number of players, how to do that?
|
|
|
|
|
<xsl:for-each select="cricket/player" order-by="name">
<tr>
<td><xsl:value-of select="@id" /></td>
.....
</tr>
and by using
<xsl:variable name="get-age" select="@age" />
and then apply IF statements on it.
for more info on using attributes go to this link:
http://www.xml.com/pub/a/2002/04/03/attributes.html
Sushant Mathur
Ocwen Financial Sol. Pvt. Ltd,
Bangalore,
INDIA.
|
|
|
|
|
Dear friends,
I want to bouild a dyanamically changing menu .Please help me on this matter. Help me please. I need a detailed complete prototype for it .
Please reply asap.
Thank you and regards
shaji
|
|
|
|
|
I am presently taking a "Crash Course" on XML in a book with that name. It tells me that in order to show a non-xml file in an XML document, I must declare, in the DTD :
1. an empty element; 2. an entity attribute for that element; 3. an entity declaration including an NDATA clause; 4. a notation, and
in the XML document, 5, an empty element consisting of the entity name and another name='filename'
Another book, XML in a Nutshell calls this way of putting a photo in an XML document "a complicated confusing mistake that should never have been included in XML in the first place" (p. 53), a sentiment that makes good sense to me.
Unfortunately, the Nutshell book neglects to explain a less complicated alternative. Can any of you tell me the most efficient manner of doing this?
DJS8
|
|
|
|
|
Can any one help me regarding Cascading Style Sheets(CSS2.0)
I need a CSS2.0 parser WRITTEN IN C++
please help me
Thanks & Regards
Gaurav Bajaj
|
|
|
|
|
I'm using C# (.NET 2.0 framework)..
Is it possible to force an XML file that doesn't reference an XSD schema to be validated against a specified XSD schema?
Here is a code segment I'm using:
XmlSchema schema = XmlSchema.Read(
new StringReader(MySchemaStringTextBox.Text),
ValidationCallback);
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.Schemas.Add(schema);
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.ValidationFlags = XmlSchemaValidationFlags.None;
XmlReader configReader = XmlReader.Create(new StringReader(MyXmlTextBox.Text), readerSettings);
XmlDocument config = new XmlDocument();
config.Load(configReader);
config.Validate(new ValidationEventHandler(ValidationCallback));
ValidationCallback never gets called, unless a schema is actually specified in the XML file.
Thanks in advance!
r -€
|
|
|
|
|
when I put an in an xsl file, the whole page becomes blank.
Please show me how to use this in an *.xsl file, or use a ' '(white space)
for example: this code is inside *.xsl file
....
....
|
|
|
|
|
Hey whenever you want to use HTML entities in your XSLT use attribute disable-output-escaping=YES and then & amp; before nbsp;in tag <XSL:text>.
check this as below:
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
Sushant Mathur
Ocwen Financial Sol. Pvt. Ltd,
Bangalore,
INDIA.
|
|
|
|
|
i have a xml looks like this
(?xml version="1.0" encoding="utf-8"?)
(?xml-stylesheet type="text/xsl" href="style.xsl"?)
(EventLog)
(Log Date="11/6/2005")
(Event)11:50:57 PM : Start Monitoring Machine: dunbshy(/Event)
(Event)11:53:54 PM : System is Successfully Loaded(/Event)
(Event)11:53:55 PM : Start Monitoring Machine: dunbshy(/Event)
(/Log)
(Log Date="11/7/2005")
(Event)12:15:33 AM : System is Successfully Loaded(/Event)
(/Log)
(/EventLog)
how do i use xsl to put all those event into a table according the it's Log Date? something liket this:
Date = 11/6/2005
11:50:57 PM : Start Monitoring Machine: dunbshy
11:53:54 PM : System is Successfully Loaded
11:53:55 PM : Start Monitoring Machine: dunbshy
Date = 11/7/2005
12:15:33 AM : System is Successfully Loaded
|
|
|
|
|
Hope this code will work for you...
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="EventLog/Log">
<b>Date =<xsl:value-of select="@*"/></b><br />
<xsl:for-each select="Event">
<xsl:value-of select="."/><br />
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Sushant Mathur
Ocwen Financial Sol. Pvt. Ltd,
Bangalore,
INDIA.
-- modified at 6:23 Monday 14th November, 2005
|
|
|
|
|
I have two different applications one for each company.
These companies are partners and need to interchange data all time betweent their apps.
Could someone give me a Guideline as to what i need to do make these apps. interchange data using XML
Both apps were created in c#
Thanks
Kourvoisier
|
|
|
|
|
- Figure out the information that needs to get exchanged.
- Write a DTD or schema describing the XML document structure that will hold the data to get exchanged.
- Create objects/methods in the two applications to read/write XML documents conforming to the standard that you developed in the last step.
- Figure out how the applications will communicate with one another: files, messages, TCP/IP sockets, etc.
- Implement the ability for the applications to exchange those XML documents over your chosen channel.
- Profit.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I currently have a bunch of XML files that represent different "file types" in my project. For example, one defines the project heirarchy, another defines a template, etc.
When the user chooses to load a new template, I don't want them to try to load in a project definition file by mistake. I only want them to see template files.
My solution thus far has been to define a unique windows extension for each "file type". Eg. ".tmpml" for template, ".prjml" for project, etc. Using a filter in the OpenFileDialog ensures that the user only sees compatible files.
But these aren't real, registered windows extentions and if a user tries to open one up from Windows Explorer, it will not be recognised as an XML file. There also may be conflicts with other applications that may use the same file extension.
Ideally what I'd like to do is to have all these files stored with the standard ".xml" extension, but have a way of differentiating them in the OpenFileDialog.
I can't think of any way to do this short of writing my own OpenFileDialog, but I don't want to go there... Is there any way to write a custom filter that looks at the file contents rather than just the extension?
|
|
|
|
|
hi,
I have some program in C# like this
XmlDocument XmlDom1 = new XmlDocument();
XmlDocument XmlDom2 = new XmlDocument();
XmlDom1.Load("Test1.xml");
XmlDom1.Load("Test2.xml");
System.Xml.Xsl.XslTransform XslObj = new System.Xml.Xsl.XslTransform();
XslObj.Load("Common.xsl");
System.Xml.Xsl.XsltArgumentList ARG = new System.Xml.Xsl.XsltArgumentList();
//ARG.AddParam("Test","urn:PC",XmlDom2);
ARG.AddExtensionObject("urn:PC",XmlDom2);
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Xml.XPath.XPathNavigator xdNav = XmlDom.CreateNavigator();
XslObj.Transform( xdNav,ARG,sw);
return sw.ToString();
I am passing a xml object XmlDom2 like
ARG.AddExtensionObject("urn:PC",XmlDom2);
Now how will i get this in the xsl(Common.xsl)
|
|
|
|
|
-- Sorry about the poor formatting, but I seem to have problems with XML tags in PRE blocks. --
I was thinking about writing a tiny app to maintain my expenses, and wanted to store the info in an XML file. I want every transaction to have a description and the amount involved. Additionally, I want the date info to be stored. Should I do it like
<transactions>
<year year="2005">
<month month="11">
<day day="7">
<transaction type="expense">
<description>Auto from station</description>
<amount>60.00</amount>
</transaction>
<!-- Other transactions for the same day -->
</day>
<!-- Other transactions for the same month -->
</month>
<!-- Other transactions for the same year -->
</year>
<year year="2006">
<!-- blah blah blah -->
</year>
</transactions>
or is there a better way? ***I don't like having an element which has an attribute with the same name***. Of course, I did come up with the idea of
<transactions>
<transaction year="2005" month="11" date="6" type="expense">
<description>Auto from station</description>
<amount>60.00</amount>
</transaction>
</transactions>
but the year, month and date attributes are ***repeated too often***.
What would you suggest? Should I simply change the nomenclature of #1 somehow, or should I go for something totally different?
Cheers,
Vikram.
|
|
|
|
|
Vikram A Punathambekar wrote: but the year, month and date attributes are ***repeated too often***.
Why? Looks fine to me. Unless you have the need to group other things by year/month/day, i don't see any reason not to use the more succinct syntax.
|
|
|
|
|
I develop web service with extensions that encrypt and compress some parameters of web method.
So I need get certain node("soap:Envelope/soap:Body/SendServiceDataInHeader/Body") in SOAP
message(got by serialization of web method) with XPath expression.
Here is SOAP message:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<ProtocolData xmlns="http://tempuri.org/">
<IsEncrypted>true</IsEncrypted>
<IsCompressed>true</IsCompressed>
</ProtocolData>
</soap:Header>
<soap:Body>
<SendServiceDataInHeader xmlns="http://tempuri.org/">
<To>zhornick@mail.ru</To>
<Cc />
<Subject>Subj</Subject>
<Body>Body</Body>
</SendServiceDataInHeader>
</soap:Body>
</soap:Envelope>
I tried with below code snippet but it doesn't work. It may be due to default namespace.
XmlDocument xd = new XmlDocument();
xd.Load("d:\\x.xml");
XmlNamespaceManager nm = new XmlNamespaceManager(xd.NameTable);
nm.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
nm.AddNamespace(String.Empty, "http://tempuri.org/");
XmlNode n =
xd.SelectSingleNode("soap:Envelope/soap:Body/SendServiceDataInHeader/Body", nm);
Of course I can get this node by writing:
XmlNode n =
xd.SelectSingleNode("soap:Envelope/soap:Body",
nm).FirstChild.FirstChild.NextSibling.NextSibling;
but it is not reliable and I want through direct XPath expression.
Help me resolve task please!
Andriy Zhornyk
|
|
|
|
|
I'm am trying to read and write some data from an AutoCad drawing to XML document, using VBA.
Can anyone assist me by providing a tutorial.
Thanks
Steven Houghton
|
|
|
|
|
The Problem: IE will sniff my data file and figure out it's REALLY in XML format, and will just render it as HTML rather than prompting the user to pass it to the application associated with my filename extension.
Description:
I have an C# Winforms application that takes data in a small input file which happens to be in XML format. Prior to this, I gave the file a custom extension (let's call it .mya for example) and associated that extension with my APP, so when someone clicked on the extension, it looked for an app already running, and if it found it, it sent that as an argument, otherwise it loaded the file itself. The app then took the data out of the custom XML file (.mya) and, among other things, sticks the data on a column in a datagrid.
Now, I'd like to set things up so when someone goes to a file like this as an URL in IE or Firefox, it will recognize the extension and call up my app. To do this, I created my own MIME type "application/myapp", had the Apache web server on the other end send the file type as that content type in its HTTP header, and then wrote to the registry under MIME/Database/Content Type my new data. I added the extension string there as .mya I then tried it out with Firefox, and it worked just fine.
It did not work at all with IE. IE sniffs the file and says, "This is actually an XML file" despite the extension and renders it as such in the browser. If I encrypt or encode the file as binary, this may force IE but I'd prefer not to do that if I don't have to.
One possibility is to get this to work with IE, I have to generate a GUID for my app and and add it under my MIME registry key as the CLSID. Then, somehow I go to my app and register this as a COM object, and support the object passing. Trouble is, I'm not sure exactly how to do that in C#.
All this seems quite complicated for something seemingly so simple. Anyone able to help me out -- perhaps there's a better way to do it. Or, perhaps generating the CLSID in the registry and then supporting that in my code is easier than I'm thinking.
Thanks a lot for everyone's help!
|
|
|
|
|
I am maintaining an application that uses the XmlSerializer to import and export data. I would like to make some modifications to the internals of the application, but I need to maintain backward compatibility with older XMLs that customers may have.
Essentially I'm trying to change
[XmlAttribute]
public string CashFlowType;
, which contains the name of the type, to this
[XmlAttribute]
public CashFlowType CashFlowType;
, which would be an object that encapsulates all of the details of the object instead of just the name.
The problem is that the Serializer can't put the complex type CashFlowType into an XmlAttribute, and rightly so.
The ideal solution would be to use [XmlElement] and write out the fields that I need to deserialize, but for the sake of maintaining backward compatibility, I cannot change the attribute to an element.
I have tried setting all of the fields of CashFlowType to [XmlIgnore] and I overrode ToString() in the hopes that the serializer would put the result of ToString in the attribute but it throws an exception just the same.
If anyone has any ideas it would be greatly appreciated.
Thanks, Jason
|
|
|
|