|
Thank you for your reply, but I think that if I do as you mentioned it won't work the way I need to be done. The scenario is as follows. The problem is that I wrote an example for the entitites that I look for but it actually dissapeared from the post message (probably because the reference is invisible). So I have an XML doc and I search for <text> tags in it, but some of these <text> tags contain character entities like & #160; (actually this is single word but I separated with a space just to be visible), and I don't want process such tags that contain this kind of information, I want to skip them. The problem is that when I select the specific nodes and I look for text entries inside them I can't recognize if an entry is a character entity just because it is substituted by the actual value of it (in the previous example I think that entity represents an empty line or whatever). I think now it is clear what I want to achive.
Thanks in advance!
|
|
|
|
|
Hi,
I want to convert MS Excel file to XML file how I can do this in .net 2005 useing C#
Girish Soni
|
|
|
|
|
Have you looked at the Office Interop library?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I am looking to get the following information from my XML:
<attribute>
<ColumnID>TestColumID</ColumnID>
<TableName>Assignment</TableName>
<ColumnName>Delta</ColumnName>
<DataType>System.Double</DataType>
<ColumnUsage>OutputColumn</ColumnUsage>
<ValueType>Single</ValueType>
<DisplayTitle>Adherence Delta</DisplayTitle>
<TypeId>ReportDatabaseColumnAttribute</TypeId>
</attribute>
If I want to print ColumnID (not the value, but the word ColumnID) from my XML tags how do I do that?
-- modified at 18:36 Thursday 25th October, 2007
|
|
|
|
|
How are you parsing the XML?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
With XSL:
Just a simple for-each attribute and then I try to us a value-of.
|
|
|
|
|
The XPath name() function returns the name of the current element.
Paul Marfleet
|
|
|
|
|
<xsl:for-each select="report/report/attribute">
<tr>
<td>
<xsl:value-of select="name()" />
</td>
<td>
<xsl:value-of select="*"/>
</td>
</tr>
</xsl:for-each>
</xsl:template>
Thats my code and all I get back is 'attribute'
|
|
|
|
|
Your context node is attribute; thus, you're printing its name. You want to print out the children elements name. It you just want to print out the first child's name:
<xsl:value-of select="child::*[position()=1]"/>
Given this XML document:
<?xml version='1.0'?>
<report>
<attribute>
<ColumnID>TestColumID</ColumnID>
<TableName>Assignment</TableName>
<ColumnName>Delta</ColumnName>
<DataType>System.Double</DataType>
<ColumnUsage>OutputColumn</ColumnUsage>
<ValueType>Single</ValueType>
<DisplayTitle>Adherence Delta</DisplayTitle>
<TypeId>ReportDatabaseColumnAttribute</TypeId>
</attribute>
</report>
here is an example of what you are trying to do except it prints out all children names:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table>
<xsl:for-each select="report/attribute">
<tr>
<xsl:for-each select="child::*">
<td><xsl:value-of select="name()"/></td>
<td><xsl:value-of select="."/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi,
i have one requirement. i am applying xslt to my xml file. it is giving one xml file like
<book>
<bookid>101</bookid>
<booktittle>Mathematics</booktittle>
</book>
i am using this one as my datasource and using this source in my crystl reports.
in field expert window i am able to see this element's data(right click on element browse data).
but the problem is if i drag these elements i am getting only element value.
so, what needs to be done for to get other element value in the report.
|
|
|
|
|
i have soml xml files generated in my local msde during net failure, and when net is back i want to get the values from local msde to servers database, i really got stucked in this point, help me out
thanks in advance
Ramkumar S
|
|
|
|
|
Hi..
Can some one please help me how to extract the data values from the following XML file using C++ code.
From the following example, we can observe two types of "CfgType"(Ane Justin and Jessica Sis). Under each "CfgType" there are different "MachineModel" and under that "ModelNo" and followed by "ScreenResolution".
<code>
<?xml version="1.0" encoding="utf-8"?>
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- Configuration Type -->
<CfgType>
<Name>Ane Justin</Name>
<MachineModels>
<MachineModel>
<ModelNo>2345678</ModelNo>
<MonitorTypes>
<MonitorType>
<MonitorName>17" LCD</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
<MonitorType>
<MonitorName>19" LCD</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
</MonitorTypes>
</MachineModel>
<MachineModel>
<ModelNo>0789456</ModelNo>
<MonitorTypes>
<MonitorType>
<MonitorName>17" CRT</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
<MonitorType>
<MonitorName>19" CRT</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
</MonitorTypes>
</MachineModel>
</MachineModels>
</CfgType>
<CfgType>
<Name>Jessica Sis</Name>
<MachineModels>
<MachineModel>
<ModelNo>456789</ModelNo>
<MonitorTypes>
<MonitorType>
<MonitorName>17" LCD</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
<MonitorType>
<MonitorName>19" LCD</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
</MonitorTypes>
</MachineModel>
<MachineModel>
<ModelNo>345678</ModelNo>
<MonitorTypes>
<MonitorType>
<MonitorName>17" CRT</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
<MonitorType>
<MonitorName>19" CRT</MonitorName>
<ScreenResolution>
<Resolution>1024*768</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
<ScreenResolution>
<Resolution>800*600</Resolution>
<RefreshRate>60</RefreshRate>
</ScreenResolution>
</MonitorType>
</MonitorTypes>
</MachineModel>
</MachineModels>
</CfgType>
</Settings>
</code>
Now, the output should be shown as follows on the console window:
Ane Justin
2345678
17" LCD
1024*768
60
800*600
60
19" LCD
1024*768
60
800*600
60
0789456
17" LCD
1024*768
60
800*600
60
19" LCD
1024*768
60
800*600
60
Jessica Sis
456789
17" LCD
1024*768
60
800*600
60
19" LCD
1024*768
60
800*600
60
345678
17" LCD
1024*768
60
800*600
60
19" LCD
1024*768
60
800*600
60
Could some one please help me in showing the output as shown above...
Many Thanks...
-- modified at 8:02 Wednesday 24th October, 2007
|
|
|
|
|
Certainly nobody will write the whole code for you. Try it yourself and if you get stuck on some specific point come back here and we'll be glad to help you. If you use .NET take a look at the System.Xml namespace. Otherwise MSXML may be interesting to you.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I suggest starting by studying MSXML. In the MSDN library (msdn.microsoft.com), it's under "Win32 and COM Developement/Data Access and Storage/MSXML" This documents some software that you can download for free from MSDN downloads.
Nathan
|
|
|
|
|
Why does this query return only one group node from the given XML? I know it's not the worlds best XML, but this is a very young prototype.
XmlNodeList groupsNodes = sectionXml.SelectNodes("Groups/Group");
<?xml version="1.0" encoding="utf-8" ?>
<Section name="ClientInvoices">
<Groups>
<Group name="Headers" driverQuery="ClientInvoices" destination="XCINVK.TXT">
<Line recordDefinition="InvHeader" />
</Group>
<Group name="Detail" driverQuery="ClientInvoices" groupKey="InvNoSort" destination="XCINVK.TXT">
<Line recordDefinition="DetailFooter" />
<Footer>
<Line recordDefinition="InvDetail" />
</Footer>
</Group>
</Groups>
</Section>
[Added 17:38]
Sorry, it was a brain fart on my part. I quickly switched to another document to compare operation, and forgot to switch back. I was querying a document with only one group. Last modified: 29mins after originally posted --
|
|
|
|
|
The following code should return an XmlNodeList object that contains 2 nodes:
XmlDocument sectionXml = new XmlDocument();
sectionXml.Load("sample.xml");
XmlNodeList groupsNodes = sectionXml.SelectNodes("/Section/Groups/Group");
Changing the XPath query produced the required output.
Paul Marfleet
|
|
|
|
|
See my mod to the message. Thanks anyway.
|
|
|
|
|
Announcing the release of Liquid XML Studio 2008
a Freeware XML Development Environment.
Download available from www.liquid-technologies.com.
Key features include
- An Advanced Graphical Schema Editor
- XML Editor, with auto-complete, syntax highlighting & validation
- Web Service Browser, supports calling Soap services
- XPath Expression Builder, visualise XPath expressions
- Documentation Generator, HTML Docs from your XML schemas
- Code Generation, C++, C#, .Net, Java, VB .Net & VB6 (trial)
Liquid XML...XML the smart way!
|
|
|
|
|
Please don't post product advertisements like this in the forums, even for free products. If you want to advertise your product, do it the right way and purchase advertising space on the site.
|
|
|
|
|
This is probably a "Doh!" moment...
I had stored some values in an XML file thus:
<?xml ... ?>
<Commands>
<Command ID="test">
<Field>f1</Field>
<Field>f2</Field>
<Field>f3</Field>
<Field>f4</Field>
</Command>
<Command ID="test2">
<Field>f1</Field>
<Field>f2</Field>
<Field>f3</Field>
<Field>f4</Field>
</Command>
</Commands>
I wanted to deserialize these into into a class so I could enumerate each command, and then the string array of fields. Long story short is I got lost in the Xml.Serialization namespace attributes, and gave up.
The root was easy, an [XmlRoot("Commands")] public class Commands which contained a Command array.
However I could not figure out how to get the Command array to return an array of Field[] strings.
Anything like public string Field[] would result in <Field><string>value</string></Field>
In the end I gave up and rewrote the XML by adding an intermediate class Fields
which I could prefix with [XmlArray("Fields"), XmlArrayItem("Field")]..
<?xml ... ?>
<Commands>
<Command ID="test">
<Fields>
<Field>f1</Field>
<Field>f2</Field>
<Field>f3</Field>
<Field>f4</Field>
<Fields>
</Command>
<Command ID="test2">
<Fields>
<Field>f1</Field>
<Field>f2</Field>
<Field>f3</Field>
<Field>f4</Field>
</Fields>
</Command>
</Commands>
But is there a way to achieve the original result??
'Howard
|
|
|
|
|
There is no direct way to achieve the original:
<?xml ... ?>
<Commands>
<Command ID="test">
<Field>f1</Field>
<Field>f2</Field>
<Field>f3</Field>
<Field>f4</Field>
</Command>
<Command ID="test2">
<Field>f1</Field>
<Field>f2</Field>
<Field>f3</Field>
<Field>f4</Field>
</Command>
</Commands>
since each <Field/> would be considered a stand-alone class field with the same name (which would be a syntax error). However, you can use XSLT to translate the deserialized format into the original format.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks - I sort of figured out that I must be doing it wrong as there did not seem to be a way to achieve it. So I wasn't missing something after all.
'Howard
|
|
|
|
|
hi,
well I've made an XSL file and I linked it to the XML file with this code
<?xml version="1.0" encoding="utf-8"?>
<?xml:stylesheet type="text/xsl" href="e2.xsl"?>
When I open the xml file in IE the result is fine. but when I open it in FireFox 2.0.0.7 it give me this error:
XML Parsing Error: not well-formed
Location: file:///d:/xsl/e_changed.xml
Line Number 2, Column 6:<?xml:stylesheet type="text/xsl" href="e2.xsl"?>
-----^
Where am I going wrong??
Thanks in advance
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
You got your style sheet processing instruction wrong. It should be:
<?xml-stylesheet type="text/xsl" href="e2.xsl"?>
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
<pre><?xml version="1.0" encoding="utf-8"?>
<b><?xml:stylesheet type="text/xsl" href="e2.xsl"?>
</pre>
<?xml-stylesheet type="text/xsl" href="e2.xsl"?></b>
These two are the same... the above line is for declaring that the document is an XML document. You're not saying I should remove the above line r u?
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|