|
|
|
Awesome! That is way better
// Steve McLenithan
Family Guy: Season 2 - Episode 8
|
|
|
|
|
Glad to help.
-Nick Parker
|
|
|
|
|
Hi,
I'm trying to read a XML file in vb. I've found some code to explain how to read it using a dataset.
The problem is that I can't read sub-section of my main table DVD.
Here is the XML code of my file :
<?xml version="1.0" encoding="us-ascii"?>
<Collection>
<DVD>
<ID>099720116493.9</ID>
<UPC>099720-116493</UPC>
<Title>Les Mystérieuses Cités d'Or L'integrale</Title>
<SortTitle>Les Mystérieuses Cités d'Or L'integrale</SortTitle>
<Description>Collector's Edition</Description>
<Regions>
<Region>2</Region>
</Regions>
<CollectionType>Owned</CollectionType>
<CollectionNumber>90</CollectionNumber>
<Rating>AL</Rating>
<ProductionYear>1982</ProductionYear>
<Released>2000-10-25</Released>
<RunningTime>974</RunningTime>
<Genres>
<Genre>Animation</Genre>
</Genres>
<Format>
<FormatAspectRatio>1.33</FormatAspectRatio>
<FormatVideoStandard>PAL</FormatVideoStandard>
<FormatLetterBox>False</FormatLetterBox>
<FormatPanAndScan>False</FormatPanAndScan>
<FormatFullFrame>True</FormatFullFrame>
<Format16X9>False</Format16X9>
<FormatDualSided>False</FormatDualSided>
<FormatDualLayered>False</FormatDualLayered>
<FormatFlipper>False</FormatFlipper>
</Format>
<Features>
<FeatureSceneAccess>True</FeatureSceneAccess>
<FeatureCommentary>False</FeatureCommentary>
<FeatureTrailer>True</FeatureTrailer>
<FeatureDeletedScenes>False</FeatureDeletedScenes>
<FeatureMakingOf>True</FeatureMakingOf>
<FeatureProductionNotes>True</FeatureProductionNotes>
<FeatureGame>False</FeatureGame>
<FeatureDVDROMContent>False</FeatureDVDROMContent>
<FeatureMultiAngle>False</FeatureMultiAngle>
<FeatureMusicVideos>False</FeatureMusicVideos>
<FeatureClosedCaptioned>False</FeatureClosedCaptioned>
<FeatureTHXCertified>False</FeatureTHXCertified>
</Features>
<Studios>
<Studio>Sony Music Video</Studio>
</Studios>
<Audio>
<AudioFormat>
<AudioLanguage>French</AudioLanguage>
<AudioCompression>MPEG Audio Stream</AudioCompression>
<AudioChannels>Mono</AudioChannels>
</AudioFormat>
</Audio>
<Subtitles>
</Subtitles>
<Directors>
</Directors>
<Actors>
</Actors>
<Review>
<ReviewFilm>0</ReviewFilm>
<ReviewVideo>0</ReviewVideo>
<ReviewAudio>0</ReviewAudio>
<ReviewExtras>0</ReviewExtras>
</Review>
<SRPInfo>
<SRP>$0.00</SRP>
<SRPCurrencyID>USD</SRPCurrencyID>
<SRPCurrencyName>United States (Dollar)</SRPCurrencyName>
</SRPInfo>
<PurchaseInfo>
<PurchasePriceInfo>
<PurchasePrice>$0.00</PurchasePrice>
<PurchasePriceCurrencyID>USD</PurchasePriceCurrencyID>
<PurchasePriceCurrencyName>United States (Dollar)</PurchasePriceCurrencyName>
</PurchasePriceInfo>
<PurchaseDate>1899-12-30</PurchaseDate>
</PurchaseInfo>
<LoanInfo>
</LoanInfo>
<Overview>Rencontre avec Bernard Deyriès Filmographie Descriptif des personnages Carte interactive des sites traversés par les personnages Bandes-annonces 39 épisodes avec documentaires de fin</Overview>
<LastEdited>2003-07-27</LastEdited>
</DVD>
</Collection></code>
Thanx
Sybux
|
|
|
|
|
Hi
I would load the xmldocument into a XmlDocument-class. Then I would use SelectNodes to fetch the proper information.
Dim lstNode As XmlNodeList
Dim xmlDoc As New XmlDocument()
xmlDoc.Load("...\...path\file.xml")
lstNode = xmlDoc.SelectNodes(strChoose)
(strChoose is the "xpathway" to your information)
(For each XmlNode in XmlNodeList, do build a string, use XmlNode.ChildNodes )
Regards
// Daniel
|
|
|
|
|
Thanks for the answer.
Is it possible to know the name of the XML Element ?
In my case I'd like to know, in the order, that I'm in :
DVD
ID
UPC
Title
etc...
Sybux
|
|
|
|
|
Hi
I guess you mean XmlElement.Name ?
Regards
Daniel
|
|
|
|
|
HI,
I'm not familiar with XML name but I just want to know (from my exemple) the name of the "category" I'm in. The category for me is <id> <utc> <title> etc...
If this is XMLElement so I need to get those information from the XMLNode (if possible).
Thx
Sybux
|
|
|
|
|
Now I´m lost, I´ve found an example from MS
Imports System
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.LoadXml("<book xmlns:bk="urn:samples">" & _
"<bk:isbn>1-861001-57-5" & _
"<title>Pride And Prejudice" & _
"")
'Display information on the ISBN element.
Dim elem as XmlElement
elem = CType(doc.DocumentElement.ChildNodes.Item(0),XmlElement) Console.Write("{0} = {1}", elem.Name, elem.InnerText)
Console.WriteLine(" namespaceURI=" + elem.NamespaceURI)
end sub
end class
You can try that one. XmlElement.Name gives the name of the node.
// Daniel
|
|
|
|
|
I need to process some fairly large (>.75Gb) XML files, (actually in a batch, but once I can cope with one, he said, optimistically...)
At the moment, I have used SAX and a FSA to parse and convert the data from XML to an internal format. However, the format changes rapidly, and the FSA is a pain to keep amending. The size means that DOM directly is a no-no.
What I had in mind was to match specific tags, and collect all the contained stuff into a smaller DOM document, which I can then process in a simplified way.
I've used DOM to read stuff before, and obviously, SAX, but not to write, so I'd be grateful for any hints or pointers to samples of this kind of thing, as I'm assuming I'm not the first to consider this option.
Steve S
|
|
|
|
|
I have been contemplating writing a generic calculation engine for Tax Computations, and was wondering if it would be possible to write such a thing that required each years coputational calculations to be defined in XML and data then to also be held in XML. The generic calculation component then uses the instructions in XML to explain how to do the calculation so that the same component can be used for any years tax computation, and output numerous results to a separate XML file.
I would appreciate any advice any of you "experts" can give me on such a project. Would it be possible??
|
|
|
|
|
>> Would it be possible??
Sure. Your basically talking about a XML Processor much the same as XSLT or any other. You define a language and then develop the processor right? Not that it is a simple task to complete but the concept is simple.
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
I want to add an XML listing to a web page - like having source code in a CP article. Is there a program that will convert it to XML and colour the tags etc?
Thanks
Davy
My Personal Blog - Homepage. Scottish News - Angus Blog, Perth Blog and Dundee Blog
|
|
|
|
|
Davy Mitchell wrote:
I want to add an XML listing to a web page - like having source code in a CP article. Is there a program that will convert it to XML and colour the tags etc?
You can use the HTML <xml> tag, the ASP.NET <asp:XML> tag, or an iframe with its source being an XML file.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
|
Hi, I am trying to create a generic xsl file to display query results. The column names depend upon the query, so I dont want to hardcode them. What I have is close to what I need, but I get one row of column headings for each row of data. (Just one would do!)
I can see that the for-each command in the table header is causing the problem, but I'm not sure how to select just one row. Any advise would be really helpfull. Thanks.
My data looks like this:
<?xml-stylesheet type="text/xsl" href="generic.xsl"?>
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
<ResultRow>
<Code>AVL1A</Code>
<Name>RED</Name>
<Quantity>9437.914</Quantity>
</ResultRow>
<ResultRow>
<Code>XYZ</Code>
<Name>BLUE</Name>
<Quantity>9437.914</Quantity>
</ResultRow></code>
And my xsl looks like this (portion):
<code><table>
<thead>
<xsl:for-each select="//ResultRow">
<tr align="center">
<xsl:for-each match=".//">
<td><strong><xsl:node-name /></strong></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</thead>
<tbody>
<xsl:for-each select="//ResultRow">
<tr><xsl:for-each match=".//">
<td><xsl:value-of /></td>
</xsl:for-each></tr>
</xsl:for-each>
</tbody>
</table></code>
Joanne
|
|
|
|
|
<thead><br />
<tr align="center"><br />
<xsl:for-each match="//ResultRow[1]/*"><br />
<td><strong><xsl:value-of select="name()" /></strong></td><br />
</xsl:for-each><br />
</tr><br />
</thead>
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Thanks, that's working now!
|
|
|
|
|
Hi,
I'm using MSXML to produce a XML Doc from a Tree Control in my VC++ program. I am getting an weird error while trying to create XMLNodes.
IXMLDOMNodePtr DOMNodePtr[100];
DOMNodePtr[i]=ptrDocIP->createElement(strRoot.AllocSysString()); //ptrDocIP is of type IXMLDOMDocumentPtr and sysRoot is CString
I'm using the above statement in a fuction and I call that fuction repeatedly to add new nodes. When I add the first nodes, I don't get any exception, but, second time I get an Exception and the program terminated.
I tried with createNode function and got the same error.
Can anybody help?
Binayak Bhattacharyya
|
|
|
|
|
whats the exception?
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi
This probably doesn´t help but when I used
lstElement->Item(0)->NamespaceURI in creating an xmlElemnt
XmlElement *NameElement = doc->CreateElement("Name",lstElement->Item(0)->NamespaceURI);
given that doc is an XMLDocument and lstElement is of type XmlNodelist. I got it to work.
But again, I assume that there are two different problems. I added elements to an existing XMLDocument.
Regards
Daniel
|
|
|
|
|
Hi !
I have a problem with serializing a class, which has a variable with an abstract-class-type.
If I'm using the specific class Test2, everything works fine,
but when I use the abstract class Test, I get the following error-message:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll
Additional information: There was an error generating the XML document.
Does anybody know whats the matter here?
using System;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace xmlTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
myObject o = new myObject();
XmlSerializer mySerializer = new XmlSerializer(typeof(myObject));
StreamWriter myWriter = new StreamWriter("test.xml");
mySerializer.Serialize(myWriter, o);
}
}
public class myObject
{
//public Test2 t = new Test2();
public Test t = new Test2();
}
public abstract class Test
{
public string s = "Test";
}
public class Test2:Test
{
new public string s="Test2";
}
}
Thank you !!!!
|
|
|
|
|
As the documentation states, serializable classes must have a publicly accessible default constructor because they are instantiated. Abstract classes cannot be instantiated, however. That is the problem.
The solution is easy: don't hardcode the type (using typeof in your example) in your serializable code. For one, one of the benefits (one could say, the "point") of using abstract classes is that you can use a generic to refer to multiple types without caring about the specific Type of the object. Instead, use o.GetType() .
Remember that in OO, even though a variable might be declared as Test or Object (pulling examples from your code), they will still be instances of myObject or Test2 . So, using o.GetType() will still return the Type for myObject (even if it were declared as an Object ).
If you use that in the constructor for the XmlSerializer , you shouldn't have any problems. This way, also, you don't hardcode that the serializer only accepts myObject . You will want to, however, use a condition or something before serializing to make sure that the object to be serialized is a Test derivative:
public void SaveTest(Test t)
{
XmlSerializer serializer = new XmlSerializer(t.GetType());
StreamWriter writer = new StreamWriter("test.xml");
serializer.Serialize(writer, t);
}
public void Save(object o)
{
if (o is Test)
SaveTest(o as Test);
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I started using SaveFileDialog in my application.
But the problem is that once I save anything to a directory different than the one that
the application is stored in, an error appears because the application can't get files in this way:
XmlTextReader reader = new XmlTextReader("loc.xml");
schemaColl.Add(null, "XMLSchema.xsd");
I can't store the absut path in my application (like that: schemaColl.Add(null, "d:\MyApp\\\XMLSchema.xsd");
Is there any simple method how to solve this problem?
Many thanks for help in advance.
misiek
-------------------------------------------------------------
My problem has been solved.
The solutions is here
|
|
|
|