|
hi,
I need to get only the values of 2 nodes in the whole XML document and Even if the nodes are repeated in the XML document I need to get only the first nodes value.
Can any one suggest how to do this with the sample code.
Thanks in advance,
Satish.
|
|
|
|
|
OK, I'll try. Use Sytem.Xml.XmlTextReader for this.
This is only example, since I don't know what nodes you want to read or how your XML file looks like.
int i = 0;
while( reader.Read() && i<2)
{
if( reader.NodeType == XmlNodeType.Element)
{
i++;
node1 = reader.InnerXml;
}
}
Does it help?
David
|
|
|
|
|
I want to make a chatting application using web services. Ne1 have an idea on how to do this?
Ur contribution is extremely valuable
|
|
|
|
|
Hi all,
I have a .xml file that looks similar to this,
<real_time_data_screen>
<screen_title>
<english>Screen Title</english>
<alternate_language>xzScreen xzTitle</alternate_language>
</screen_title>
<screen_classification>4294967295</screen_classification>
<screen_group>256</screen_group>
<guage_configuration>
<name>
<english>Guage Name</english>
<alternate_language>xzGuage xzName</alternate_language>
</name>
<guage_id>2</guage_id>
<units>
<english>Units</english>
<alternate_language>xzUnits</alternate_language>
</units>
<minimum>1</minimum>
<maximum>10</maximum>
<sections>
<number>10</number>
<limits>10</limits>
<color>234</color>
</sections>
</guage_configuration>
<analogue_variable>
<name>
<english>Variable Name</english>
<alternate_language>xzVariable xzName</alternate_language>
</name>
<input_values>
<minimum>1</minimum>
<maximum>10</maximum>
</input_values>
<output_values>
<minimum>1</minimum>
<maximum>10</maximum>
</output_values>
<needle_color>234</needle_color>
<guage_id>2</guage_id>
</analogue_variable>
<digital_led>
<name>
<english>LED Name</english>
<alternate_language>xzLED xzName</alternate_language>
</name>
<variable_id>2</variable_id>
<clear_color>255</clear_color>
<set_color>0</set_color>
</digital_led>
</real_time_data_screen>
I need to read through this file and create objects and update attributes depending on the data in this file. The objects will be screen, gauge, analogue and digitalLed. I've got very basic knowledge of xml and can just about read through the file and get elements and the corresponding value. How would I best go about reading throuh the file and when I find a screen tag (for instance) create a screen object and anything within that tag be written to the object.
Hope this makes sense and thanks in advance.
|
|
|
|
|
Not any ideas???
|
|
|
|
|
you may want to have a look at serialization check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml01202003.asp[^]
or maybe do a search on google for serialization. I think (not sure here) but you need to have an object already defined before you can deserialize xml to it.
Another way (and im not sure if it is a good way) would be to go through the xml similar to this way:
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.load(xmlSource);
XmlNode screenNode = doc.documentElement.selectSingleNode("//real_time_data_screen")
now you have your screen portion of the xml and you can use that node to select whatever you want from the screen section e.g.
screenNode.selectSingleNode("//screen_title")
Something like that I anyways.
|
|
|
|
|
Thanks for the help. I'll look at it over the weekend and hopefully sort it out. I've sort of got it doing what I want but it's not retty and I know there's a better way.
Thank again for the pointers.
|
|
|
|
|
This is what I came up with,
I used the XmlTextReader class to read start elements and then read the element strings. Info on the XmlTextReader class can be found here
Here's a small sample
vReader->ReadStartElement ( "screen_title" );<br />
m_screen->EnglishTitle = vReader->ReadElementString ( "english" );<br />
m_screen->AlternateTitle = vReader->ReadElementString ( "alternate_language" );<br />
vReader->ReadEndElement ();
m_screen->Classification = vReader->ReadElementString ( "screen_classification" );<br />
m_screen->Group = vReader->ReadElementString ( "screen_group" );
Not great but for small simple Xml files this seems to do the job required.
|
|
|
|
|
Hello,
What are the minimum IE requirements for DOM and XSLT?
|
|
|
|
|
What do you mean by minimal requirements? Version of IE? here[^] are features of newest IE... look for DOM and MSXML features. However I don't know since when these features are present in IE, nor do I know if it was really your question.
David
|
|
|
|
|
Version 5, I believe. But you can download the MSXML dll seperately, I dunno how well it fits in with IE if you do.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have just been put in charge of designing an infopath form to integrate into sharepoint services. Since I'm new to infopath, I need some help with a few things. First, I need to be able to load a picture from a link on the sharepoint list without using base64. Second, I have to have a text box which will update the database entries shown as the user types. Right now I have been using conditional formatting, but I'm unsure how to get the text box to trigger it after every character entered in the control.
Thanks in advance
-- Steve
|
|
|
|
|
Hi! I was just given a project to read XML from a server and display the contents in our software. I figure there's an XML parser out there I wouldnt have to reinvent it, but I'm not sure what/where/how etc. I learned XML/XSL/XSLT 2 yrs ago, barely used it, and never with C++.
CAn someone give me info/advice on where to start? I'm not a DOM/COM expert just a C++/VC++ developer who's done more communication development than web stuff.
Any help would be useful. I have books on XML/XSL/XSLT, but none relating it to C++.
THanks in advance.
-C
|
|
|
|
|
Wheatbread wrote:
I figure there's an XML parser out there I wouldnt have to reinvent it, but I'm not sure what/where/how etc.
Have you tried this[^]?
David
|
|
|
|
|
I'm looking for any C++ developers interested in testing a new XML library focusing on a simplistic public interface. Developers of almost any skill are welcome to submit a request. Either e-mail me directly or leave a message along with your e-mail address in this topic. A lot of people have expressed a great interest in the project, and I along with them, believe it'll create a massive impact in the world of Open Source.
Just send the e-mails to skonen@gmail.com . Anybody who is interested in giving it a try needs to be proficient in English and have no fear with letting their opinions be heard.
|
|
|
|
|
Hi,
I am including System.XML but
XMLTextReader reader ;
this statement is creating build time errors.
"The type or namespace name 'XMLTextReader' could not be found (are you missing a using directive or an assembly reference?)"
Any idea about this ?
|
|
|
|
|
From what you said, try using System.Xml; and class is called XmlTextReader . Note that it is "Xml" not "XML". Case matters.
David
|
|
|
|
|
hi,
I want to write the code using SAX technique in C#. Any body can give me some links where I can find sample code and some resources !!
Thanks in advance
|
|
|
|
|
letusC# wrote:
Any body can give me some links
MSDN[^]
I do not mind getting old. It beats all the other options that I can think of.
|
|
|
|
|
Friend;
One of my young/just out of college co-worker use XML to holder information in record, instead of using database fields like normal.
for ex:
In an Order table he would use a short table with only OrderId and OrderXML columns
where in field OrderXML he keep a long XML which hold all OrderDate, QTY, Price,etc..)
His argument is this will make application scalable, but this really cause me a greate concern that his application will be un-scalable since he can not use all the feature DB, SQL provides. And he has to handcode every steps.
I heard XML is for data interchange but never hear XML is for data processing
You have more experiences with XML than me. Please advise if he is ok
Thanks
|
|
|
|
|
Mixing what is meant by scalable.
In the OrderXML field, you can extend the contents without redefining the database. So it scales.
As you point out XML is not a DB. So the ability to query and sort is limited and potentially very time consuming. Yes new versions promise support for XQuery and queries into xml enteries but this is hardly proven IMhO. And I am very much a XML evangelist.
All the standard fields to support your orders I would have as db fields. With extensible data that I do not need to search on, in the OrderXML.
XML is for data interchange and support data reformating very well, which I would call data processing but not in the sense you state.
my 2 cents.
I do not mind getting old. It beats all the other options that I can think of.
|
|
|
|
|
Hey
At the moment im busy with a document collaboration that would be in essence making use of xml documents in the same way. Yeah, its kinda jump doing so, but if it can be perfected (when i say perfected i mean efficient reporting, etc.) it would definitely be the next step in efficient document collaboration. Dodgy, yes, but it forms part of my research as well. Could you do me a fav & get your friend to maybe send me a mail, Id like to know how the implementation of the system went/is going?
Cheers
|
|
|
|
|
Hello friends,
i want to create an XML document through VB6.This document is to be imported in TALLY.
please do help me
pallavi
|
|
|
|
|
Hi people,
ich have two xsl files to convert a xml file to a pdf and to a html.
the question is:
is there any way, that i put this two xsl files in one whole xsl file. which can be configured to convert the xml file to a pdf or a html. maybe a variable in xsl file or something like that..
--------- This one is for conveting to pdf ---------------------
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><br />
<br />
<xsl:template match="/tagebuch"><br />
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"><br />
...<br />
</fo:root> <br />
</xsl:template> <br />
</xsl:stylesheet>
----------------------------------------------------------------
--------- This one is for conveting to html ---------------------
<xsl:stylesheet version="1.0" <br />
xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><br />
<br />
<br />
<xsl:template match="/"><br />
<html><body><head><title>Tagebuch</title></head><br />
...<br />
</body></html><br />
</xsl:template><br />
</xsl:stylesheet>
-----------------------------------------------------------------
I would be very happy for a tip or a help..
thanx in advance
|
|
|
|
|
Maybe you could use the xsl:param element (
http://www.w3schools.com/xsl/el_param.asp).
<xsl:param name = "outputType"/>
Then you can put the two stylesheets in a choose structure (http://www.w3schools.com/xsl/el_choose.asp)
<xsl:choose>
<xsl:when test = "$outputType = 'PDF'">
... PDF template ...
</xsl:when>
<xsl:otherwise>
... HTML template ...
</xsl:otherwise>
</xsl:choose>
Haven't tried it, but you may need to modify your XSL. I suspect you cannot put an xsl:template inside an xsl:choose structure.
|
|
|
|