|
What version of MSXML are you using? And how are you planning on go about this application wise?
Matthew R. Sannes
Docsoft
Technical Marketing Specialist
www.docsoft.com
msannes@docsoft.com
|
|
|
|
|
I have an xml document with 3 topic elements: Topic1, Topic2, Topic3
I have an xsl stylesheet that has a topic template. I want to be able to select different combinations of topics using xpath and a parameter.
To select all topics I use this: Content/Topics/Topic
To select just Topic1, I use this: Content/Topics/Topic[@name='Topic1']
I have a param named MatchTopic and I want to select any combination of Topics, say Topic1 and Topic2 or Topic1 and Topic3 or Topic2 and Topic3.
I tried this:
<xsl:apply-templates select="Content/Topics/Topic[$MatchTopic]"/>
with the following param value:
<xsl:param name="MatchTopic">Content/Topics/Topic[@name='Product Updates' or @name='Management']</xsl:param>
and it doesn't work. Nothing I try works.
Is it possible to call this template and select any combination of topics using a parameter?
Thanks in advance.
|
|
|
|
|
yes, but you have to use an extension..
msxsl:node-set
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
I am trying to create an xml file from an xml file using vb.net and XmlTransform .
My xsl file has this line
xsl:output method="xml" version="1.0" encoding="UTF-8" cdata-section-elements="Column"
I want to wrap the data in the node Column in CDATA tags. This works in vbScript and tesing using XML Spy but in the asp.net page using XmlTransform the node does not get wrapped in CDATA Tags.
Any help would be great I am in a bind.
|
|
|
|
|
I'am quite new to XML in .NET and would appreciate some advice on the correct way to iterate through an XML document I have created like:
[XML DOC]
[OuterList]
[ListItem image="C:\pic1.wmf"]
[InnerList]
[Item Atr1="ABC" Atr2="DEF" Atr3="GHI"/]
[Item Atr1="123" Atr2="456" Atr3="789"/]
[/InnerList]
[/ListItem]
[ListItem image="C\pic2.wmf"/]
[InnerList]
[Item Atr1="ZYZ" Atr2="WVU" Atr3="TSR"/]
[/InnerList]
[/ListItem]
[/OuterList]
- note I have replaced the XML tags with []
I would only want to go to a specific item in the outerlist, and then read each item in its innerlist.
|
|
|
|
|
Learn a little about XPATH queries. The System.Xml.XmlDocument class supports a method, SelectSingleNode which you would use to get to the specific <OuterList> node. Am I correct in thinking you have some kind of identifier for your <OuterList> nodes? If you have an id attribute or something you could use SelectSingleNode to get the node with that specific id . For example, say you have your Xml doc with the <OuterList id="124">. You can get that node as follows:
XmlDocument doc = new XmlDocument();
doc.LoadXml([doc string here]);
XmlNode outerListNode = doc.SelectSingleNode("descendant::OuterList[@id='124']");
Once you have the node, you can further use SelectSingleNode to get another node underneath that you're interested in, such it's child <ListImage> element, e.g., XmlNode listImageNode = outerListNode.SelectSingleNode("descendant::ListItem") and grab the image attribute by listImageNode.Attributes["image"].Value -- of course, checking for null s and errors all the while -- Never forget error checking!
Alternatively, you can just iterate through the outerListNode.<a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemxmlxmlnodeclasschildnodestopic.asp?frame=true" target="_blank">ChildNodes</a> and handle it as you encounter them (in a foreach loop.) This approach, however, is overkill for your case.
Another alternative is to create a class structure using Xml Serialization and the XmlSerializer. This way you can handle the <OuterList> items as part of an object collection in your document representation class.
There are several ways to approach this using .NET. I suggest you peruse the MSDN dox, as well as articles here.
Good Luck!
|
|
|
|
|
Hi..
is it valid to nest an XML tag within a tag of the same type ?
like this :
<Drive name="C">
<Folder name="folder1">
<Folder name="New Folder"/>
</Folder>
</Drive>
|
|
|
|
|
You're not really nesting. Nesting would have a <Folder> or <Drive> element within another <Folder> or <Drive> element.
Oh yeah, yes it's legal as long as it's well-formed:
<drive dev="/dev/hda1">
<folder name="bin"/>
<folder name="usr">
<folder name="bin"/>
<folder name="sbin"/>
<folder name="src"/>
<folder name="darwin" link="true"/>
<folder name="include"/>
<folder name="linux" link="true"/>
</folder>
</folder>
<folder name="sbin"/>
</drive>
The W3C says, "A consequence of well-formedness in general entities is that the logical and physical structures in an XML document are properly nested; no start-tag, end-tag, empty-element tag, element, comment, processing instruction, character reference, or entity reference can begin in one entity and end in another."
|
|
|
|
|
I'm reading xml from SQL server with VB.net using an XSD schema file. I have the code working fine, but I'd now like to change the code from reading a file on disk to reading the schema from the file as an embedded resource. Here's my code, what do I need to change??
<br />
Dim conString As String = "MyConnectionString"<br />
Dim strm As Stream<br />
Dim strmReader As StreamReader<br />
Dim cmd As New SqlXmlCommand(conString)<br />
Dim xmlDoc As New XmlDocument<br />
Dim strXML As String<br />
<br />
With cmd<br />
.CommandText = "MyXPath"<br />
.CommandType = SqlXmlCommandType.XPath<br />
.SchemaPath = "C:\MySchemaFile.xsd" '**I want this to be embedded!!**<br />
strm = .ExecuteStream<br />
End With<br />
<br />
strmReader = New StreamReader(strm)<br />
strXML = strmReader.ReadToEnd<br />
xmlDoc.LoadXml(strXML)<br />
Like I said, the above code works fine, but I don't want a physical file location.
Thanks!!!
-Michael
|
|
|
|
|
Add the XSD to the project, change it's build type to Embedded Resource. You'll use the Namespace to get at it. For example, if your assembly default namespace is MyDataAccess , the resource base name will be MyDataAccess.MySchemaFile.xsd . You'd use Assembly.GetExecutingAssembly().GetManifestResourceStream to load it.
Unfortunately, SqlXmlCommand only accepts paths to the SchemaPath So, you embed the XSD, then write it out as a temporary file, use it, and delete the temporary file:
string tmpFilePath = Path.GetTempFileName();
try
{
TextReader rdr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("MyDataAccess.MySchemaFile.xsd");
TextWriter wr = new StreamWriter(tmpFilePath, false);
wr.WriteLine(rdr.ReadToEnd());
wr.Close();
rdr.Close();
}
catch (Exception e)
{
}
finally
{
if (File.Exists(tmpFilePath)) File.Delete(tmpFilePath);
}
|
|
|
|
|
i am currently trying to create a combo box which will then display "yes" and "no" when i run the macro, the combo box is created in visual basic!
any feed back would be appreciated!
sincerely
hyper Robster
|
|
|
|
|
I'm trying to develop a web based C# app that will read in any xml document and then display the information in a tree form. The user can then expand the parent nodes through a drilldown list and edit its children. Anyone know how I can go about doing this? I've only been able to get the app to update/add/and edit but I don't know how to display the hierarchy. Any help is appreciated.
|
|
|
|
|
How do I put a string into a xml file in a windows application, in a window form? I use a DataReader for accessing data from my database(and not a dataset).
When I was working to a project in ASP, I used
xmlfile.DocumentContent=mystring;
but in windows forms the xml document doesn't have "DocumentContent" property!
|
|
|
|
|
Well yeah, you just can't arbitrarily stick a string into the middle of XmlDocument . Can you elaborate on what you are trying to accomplish? You are iterating over a DataReader for data to do what with it? If you want to insert a new XmlNode into the XmlDocument there are plenty of examples of how that works around.
|
|
|
|
|
Why not use a dataset? Then you could retrieve the xml using the getxml and insert your nodes as required.
|
|
|
|
|
I'm serializing an object (mydata).
What is the code so that the output xml shows:
<mydata
xmlns:xsi='http: www.w3.org="" 2001="" xmlschema-instance'
xsi:nonamespaceschemalocation="myOwn.xsd"
------
<="" mydata="">
The .xsd is given to me. I don't have to create it, I only need some means to getting the two lines above(xmlns... and xsi...) to pop out in the XML when the object is serialized.
Thank you
Larry
|
|
|
|
|
Hello friends,
I got many xml parsers from both third party persons and also MSXML. I would like to know which parser will use less memory? Since i am going to use the parser in Pocket PC system.Please help me.
Thanks
JP
|
|
|
|
|
If you need just need to parse XML, Pocket PC 200o Pro and Pocket PC 2002 comes with MSXML 2.0 parser. Also you can check for SAXON parser support for Pocket PC.
If you need to do XSLT Transformation, Pocket PC 2003 (Windows Mobile) comes with MSXML 3.0 support which is pretty good. You can also try XALAN.
Since MSXML already comes in Pocket PC, I guess, it should work fine with the low memory.
|
|
|
|
|
If you need just need to parse XML, Pocket PC 200o Pro and Pocket PC 2002 comes with MSXML 2.0 parser. Also you can check for SAXON parser support for Pocket PC.
If you need to do XSLT Transformation, Pocket PC 2003 (Windows Mobile) comes with MSXML 3.0 support which is pretty good. You can also try XALAN.
Since MSXML already comes in Pocket PC, I guess, it should work fine with the low memory.
|
|
|
|
|
Hi Thanks for your suggestion. I need XML parser only. So no problem. But I don't know how to use MSXML.That is the big problem. Can u give me some samples for XML parser using MSXML
Thanks
JP
|
|
|
|
|
Does anybody know if Visual Studio .NET (or other tools) can automatically generate sample xml files (for testing, for example) from a given xml schema? (IBM used to have something like that for a given DTD).
Thanks.
|
|
|
|
|
I thought XMLSpy could do that.
|
|
|
|
|
Hi Mark,
Thanks for the info, XMLSpy is not free, I think. Does Visual Studio .NET or some other Microsoft development tools provide that capability?
Thanks.
|
|
|
|
|
You can get it as a trial version.
|
|
|
|
|
I have searched MSDN and Microsoft and found a page which suggests I download some documentation. No download appears. Does anyone know where there is a downloadable version of the Word XML reference. I have the Excel Worksheet reference for Excel 2002 but not Word.
|
|
|
|