|
There are a lot of ways to do it - here's some suggestions:
- The DOMTreeWalker lets you set up a node filter. You can set up a filter to accept all element nodes whose tag is Locomotive. That means that each call to the DOMTreeWalker's nextNode method will step to the next Locomotive element. For each of these, you iterate through the found element's child nodes. Each child's tag name indicates which struct memeber they relate to, while the child's text node is the value that you'll convert to the correct type using string conversion functions like strtol.
- From the root node, apply an XPath of "//Locomotive". That'll get you all the Locomotive elements, which you can process as above.
- Get a DOMElement for the root element of the XML document. Use the getElementsByTagName method to retrieve all descendent nodes with the tag naem Locomotive. Process each node as indicated above.
Hope that helps you!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
But still i am finding difficulty
could you please give me a example...............
|
|
|
|
|
VVVimal wrote: could you please give me a example
This[^] indicates this sample[^] which may be helpful, as well as many other pages.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
DOMElement* elementRoot = domDocumet->getDocumentElement();
DOMTreeWalker *walker =domDocumet->createTreeWalker(elementRoot,DOMNodeFilter::SHOW_ELEMENT,NULL, true);
DOMNode *pCurrent = NULL;
for ( pCurrent = walker->getCurrentNode();pCurrent != 0; pCurrent = walker->nextNode() )
{
if(pCurrent->getNodeType() == DOMNode::ELEMENT_NODE)
{
char *str = XMLString::transcode(pCurrent->getNodeName());
if(!strcmp(str,"LocoId"))
int i=0;
//myDetails->LocoId = XMLString::transcode(text->getNodeValue());
if(!strcmp(str,"Latitude"))
//myDetails->Lattitude = XMLString::transcode(text->getNodeValue());
XMLString::release(&str);
}
}
Could you please tell me where to set the filter as Locomotive
you also mentioned "From the root node, apply an XPath of "//Locomotive "
what does it mean
Thanks
you also mentioned as
|
|
|
|
|
Set the filter in the createTreeWalker method call.
VVVimal wrote: you also mentioned "From the root node, apply an XPath of "//Locomotive "
what does it mean
Using an XPath[^] library such as Xalan[^] or XQilla[^], you apply an XPath evaluator class to the DOM. That will give you an iterator that'll go through the nodes that match the XPath expression you gave to the XPath evaluator.
Read up on XPath - it's a very useful tool to know how to use.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
how do a code a button save a save file dialog must appear and a user must choose a location where to save in vb.net
|
|
|
|
|
If you would like an answer to this:
0) You need to use the VB .Net forum
1) Please don't double post, be patient and keep your posts together so people can see what has been suggested
2) You will need to show what you have already tried, and where it goes wrong. People won't write the code for you
3) Give as much detail as possible. You seemed to be on the right track with your last post, but we don't know how you're storing your XML in your code, how you want to store it on the disk, etc.
|
|
|
|
|
I already answered this question below. Please do not double post the same question.
|
|
|
|
|
I suggest you buy a book, probably one with the word 'dummies' in the title.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Actually a brilliant answer
|
|
|
|
|
Good Day i have Add Rotator and one of my XML looks like this
Now i get an Error when i try to use this,the XML does not like it. the Error says
<<NavigateUrl>>http:
Now i get an Error when i try to use this,the XML does not like it. the Error says
Expecting ';'
Dont mind the Extra Brackets. The Problem is on the Bold parts
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
& is a special character in XML, which is used with ; to display some symbols and special characters. Replace all the ones in the URL with & and your error should go away.
|
|
|
|
|
Thank you Very Much
That worked
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
No problem at all
|
|
|
|
|
here is my code it only opens the dialog but doesnt save anything
Dim filepath As String = String.Empty
If (sfdSaveSurvey.ShowDialog() = Windows.Forms.DialogResult.OK) Then
filepath = sfdSaveSurvey.FileName
End If
'xmldoc.Save( filepath )
|
|
|
|
|
ndumy wrote: 'xmldoc.Save( filepath )
I don't know much about VB but that line looks suspiciously like a comment.
|
|
|
|
|
We need to hard code some special characters in xsl so that it printsthe exact hard coded value in the dynamically created asp.net cs files.
Ex: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Testing.aspx.cs" Inherits="Testing">;
Also when try to hard code the below line in xsl, the editor understands the "DOCTYPE" as DTD document.. SO please help me out in this. How to hardcode these two lines in xsl.
;
Thanks,
Santa
|
|
|
|
|
I suspect CDATA sections[^] will be useful for this.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi All,
We have a C# windows application which will transform the xml and xslt we give into a .aspx page. The user has to specify the XML and the .aspx file name , we have a standard XSLT which will use the xml and create the file with the name specified by the user. The problem we face is in the .aspx page we want to write the Page attribute E.g. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" >; where we include the .aspx.cs file name , but this value comes from the C# code , how can we import the textbox value from C# code into our standard XSLT to write the page attribute in our to be generated .aspx page. Please Advice.TIA
Regards,
Nancy
|
|
|
|
|
Add a parameter at the top level of the XSLT file:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsl">
<!-- Allow the user to specify the .cs filename -->
<xsl:param name="CSFilename"/>
<!-- The rest of your XSLT - use $CSFilename to access the .cs filename -->
</xsl:stylesheet>
You then use the XsltArgumentList[^] class to add the parameter values when you perform the transform.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
If you can add an XSD schema to a .docx and add the elements to the doc itself, then how do you send data to this? Can you use word automation via VB.Net 2008?
|
|
|
|
|
Hi All,
We have two .xml files, one has the details about categories and in the other .xml file we need to reference the categories. When we searched in net we found that we need to declare the categories as entities in the DTD file and use them in the xml, but we want to take the categories from the xml file only. Kindly advice. TIA
Regards,
Nancy
|
|
|
|
|
You could use XInclude to logically include the 'categories' XML file in the file that needs to reference the categories?
A question - when do the category usages need to be resolved to the original categories? What processing step *NEEDS* the link between category use and category definition to be available?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for your help.
In brief we have an xml file (kind of Master XML) which has all categories and Values for Each category Eg. Technology, Department will be categories, Technology will hold values like Technology_id and Technology_name, same for department.
We have another XML(Pagewise) which describes about what controls should be in each page. E.g. Listbox, Button , Radio button. The XSLT file will use the Pagewise XML to get details about the controls and the master xml to get the details about the values to be stored in controls like Listbox.
We are actually trying to create dynamic .aspx pages using XML and XSLT.
Regards,
Nancy
|
|
|
|
|
If you're using xslt, then there's always the document function[^] that allows you to read in a separate XML document.
Alternatively, the XInclude[^] suggestion will work with XSLT, provided your XSLT processor has support.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|