|
Hi, can anyone help me please! I'm trying to load this sipmple XML into memory and then store the XML data into a structure so that my other programs can access this structure for retrieving data when needed. The XML document is:
<contact>
<personal>
<name>John Moss
<age>28
<house_number>8
<street>Polygon Road
<town>London
<country>UK
<sport>
Karate
<belt>Second degree black belt
<champion>1992 1994 1995 1996
So far I can only managed to load and display this document using (MSXML4)XMLLoad but how can I store these data into C/C++ structure? Please help as I'm completely terrible at C/C++ . Many thanks!!
|
|
|
|
|
>> but how can I store these data into C/C++ structure
well the document object ur creating using MSXML IS a tree structure so u already have one eh? if u need it to be in a different structure then can u expand on that?
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Hi Palbano, thank you very much for the reply, I understood that the DOM is already a tree struture, what I'd like to do is to transfer these data into another structure written in C/C++, which unfortunately I'm very terrible at. Would it be possible if you can show me how this is done by providing an example skeleton code. Much appreciated!
|
|
|
|
|
Say i had this ...
<A>
<B>data</B>
<C>
<D>first</D>
</C>
<C>
<D>second</D>
</C>
</A>
and I want this ...
<A>
<B>data</B>
<C>
<D>first</D>
</C>
</A>
What would be the xpath statement ?
something to do with C[1], but I am stumped after that
- james
|
|
|
|
|
something like 'ancestor-or-self::a/b/c[0]/d'. I can't remember, is it 0 or 1 based, the indexing ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
|
Christian Graus wrote:
I can't remember, is it 0 or 1 based, the indexing ?
1 based
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Let's say I have a complex type defined in the schema:
<xs:complexType name="DataSetType">
<xs:sequence>
<xs:element name="DataSetName" type="xs:string" />
<xs:element name="Description" type="xs:string" />
<xs:element name="DSREvent" type="xs:string" />
<xs:element name="Datum" type="DatumType" />
</xs:sequence>
</xs:complexType>
The corresponding XML looks something like this:
<DataSet>
<DataSetName>CalcItemTax</DataSetName>
<Description>Determine the tax on the item</Description>
<DSREvent>CalculateItemTax</DSREvent>
<Datum>
<DatumName>TaxExempt</DatumName>
<Description>Flag indicating customer is tax exempt</Description>
</Datum>
<Datum>
<DatumName>Taxable</DatumName>
<Description>Flag indicating item is taxable</Description>
</Datum>
Is there a single XPath statement I can use to extract just the DataSetName and the DSREvent, for example, with both returned as children IN THE SAME NODE???
If I use the '|' operator, I get two nodes for every line.
Any ideas?
Thanks,
Marc
<small><a style='color:black'>Help! I'm an AI running around in someone's f*cked up universe simulator.</a><br>Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus<br>Every line of code is a liability - Taka Muraoka<br>Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"</small>
|
|
|
|
|
If I am reading your question right, I think you want to look at the usage of <xsl:value-of select="xpath_a"/> ... <xsl:value-of select="xpath_b"/>
to create the data for a single new element that combines the data from the two you had.
If you are wanting the elements then I do not understand your question because you do have two elements (or nodes) before and after.
edited (check display as is stupid!)
<b><i>"I will find a new sig someday."</i></b>
|
|
|
|
|
Well..., I guess I'm confused.
Is XPath and XSL interchangeable? I'm not sure how to set up an XSL query in C# using the XmlDataDocument.SelectNodes method (and I don't really want to get into implementation specifics, I just want to figure out the right XPath command, if one exists!).
At this point, I don't even know what the right question is to ask. I basically want something that returns an XmlNode with two children--the DataSetName text field and the DSREvent text field.
Seems this shouldn't be so dang hard, and if it's not possible, this seems like a real limitation of XPath.
Marc
Help! I'm an AI running around in someone's f*cked up universe simulator. Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus Every line of code is a liability - Taka Muraoka Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"
|
|
|
|
|
Marc Clifton wrote:
Is XPath and XSL interchangeable?
The straight answer to that is no.
XPath is a thecnique that is used in XSL transformation to identify what it is to work on.
Now that what can be in respect to the whole document. I.E. what element to start with and it can be relative to its starting point or the element it that is currently the reference point.
Once you have identified a starting element you can copy elements in whole or create new element and then assign data to those elements (new or the copied ones). One method of getting data from existing XML is the value-of Now to confuse you. internal to the value-f is a select option that you may say what data you want. And guess what, you can use the XPath in that select statement.
At this point I am probably getting you fairly confused, sorry.
Do you have any XSLT reference books? It may be a worth while effort to get one. Michael Kays is a good book and amazon has it for I think $25. I do not have it just because one of "my guys" has it. Or I would have purchased it. The other book I would recommend is Holzners Inside XSLT book from New Riders. It is not as good in the explaination but is better with samples. It also is found in the used area on amazon for under $10. (6.98)
I will be happy to continue if I am helping you. I will be honest though, I have been leading a group now for about 18 months and they do the day to day coding and I am getting rusty.
"I will find a new sig someday."
|
|
|
|
|
I didn't know you were so into XML. Maybe another Soda Springs venture may be in order...
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Hi!
which XML schema do you prefer and why?
thanks
John
|
|
|
|
|
Hi, everybody!
I found 10 XML seminars here at http://www.only4gurus.com. They have more than 1500 documents about everything Microsoft related. It´s all free for download (or almost, since they put all those banners popping around, but I suppose this annoying things are cookies controlled because they stop after some time). Do you know where to find more like these? I want some more!
Thanx,
Carlos Aquino
|
|
|
|
|
|
Nevermind, sorry, thanks
Wrong path in.xsl deleted "TEAMS/"
Later, JoeSox www.joeswammi.com
Load my Sig here.....
|
|
|
|
|
Hi
I was unsure if non transformed XML files (ones without a XSL/XSLT file attached to it) are indexed by search engines or not?
Also if you have all your dynamic pages rendered by a single file (default.asp for example) which gets its data from XML or SQL or whatever and only the querystring differs, will each differing page be indexed as a different page ?
Cheers
|
|
|
|
|
Hi all,
I'm not sure if this is the right place to post, but...
Is there any way to control the WSDL produced in a VS.NET C# Web Services Project? I'm guessing it might be something involving attributes.
Basically, I'm using SOAP to return subsets of a database, and I think DataSet et. al. may be a little to heavy-weight for what I need. An example of what I want is a SOAP function GetAuthorInfo( UINT id ) that returns an author's details as XML, conforming to a predefined Schema. I'd like to be able to specify this Schema in my WSDL file.
I'm new to the whole SOAP/XML/Web Service thing, so I'm not sure if this is a really naive way to implemnt this kind of functionality, so any comments and suggestions are most welcome.
TIA,
Pete
|
|
|
|
|
Greetings,
Just when I thought I was getting better at XML/XSL I come across an article on MSDN with an XSL transform that has me puzzled. The basic premise is to use a DataAdapter to attach to a SQL DB, and DataSet to hold the data and and XSL to transform that data into an XML island for consumption by a control (almost exactly what I am trying to do).
Here is the portion of the XSL in question:
<xsl:for-each select="MyDataset/Table">
<xsl:text disable-output-escaping="yes">
<z:row lastname="</xsl:text>
<xsl:value-of select=" lastname"="">
<xsl:text>" OrderTotal="
<xsl:value-of select="OrderTotal">
<xsl:text disable-output-escaping="yes">"/>
And here is the exception that is thrown by this section of XSL:
<', hexadecimal value 0x3C, is an invalid attribute character. Line 22, position 19.
So what exactly is this for-each statement trying to do and why is it failing?
Your feedback would be greatly appreciate!
Rhoam
|
|
|
|
|
Ok, that didn't come out right. I've changed the brackets to <- and -> so the code would show. Sorry about that.
<-xsl:for-each select="MyDataset/Table"->
<-xsl:text disable-output-escaping = "yes"->
<-z:row LastName="<-/xsl:text->
<-xsl:value-of select="LastName"/->
<-xsl:text->" OrderTotal="<-/xsl:text->
<-xsl:value-of select="OrderTotal"/->
<-xsl:text disable-output-escaping = "yes"->"/><-/xsl:text->
<-/xsl:for-each->
|
|
|
|
|
Hi
I am trying to build a generic function to building forms using only ASP3.0, XML and XSLT.
The idea/theory is to be able to create a form holding any number of differing elements simply by passing a single variable to the XML and XSLT which would tell it which node in the XML to get the form structure. There by allowing control/creation of numerous forms simply through adding nodes to the xml file. Also the only time I want to hit the database is to insert the form data or pull values for an "edit form" feature (see below). The XML and XSLT will be standard text files, not stored on the database.
I have managed to the the form built correctly. The form layout is determined by the XSLT file and the form elements and thier associated attributes are based upon the XML file contents.
The problem I have run into is if I want to render a form which has one/some/all of the elements prepopulated I cannot do this in a generic fashion as I have to know exactly the quantity of parameters to have in the XSLT and to which bit in the XSLT they belong to.
Is there any way of using arrays within XSLT? If so I could then pass an array to it using ASP that is filled with either values or NULL's whereby I can do something like
<INPUT NAME="@NAME" TYPE="TEXT" MAXLENGTH="@MAXLENGTH">
<xsl:if test="$array[x] != 'NULL'">
<xsl:attribute name="VALUE">
<xsl:value-of select="$array[x]" />
</xsl:attribute>
</xsl:if>
</INPUT>
Where x corresponds to the element in question.
Current example:
http://www.safari-trader.com/functions/form_builder/index.asp
http://www.safari-trader.com/functions/form_builder/forms.xml
http://www.safari-trader.com/functions/form_builder/forms.xslt
Any help/pointers would be appreciated....
John
|
|
|
|
|
John,
I think what you want is XForms, not XSLT.
Have a look at this (slightly outdated but nonetheless a good intro): http://www-106.ibm.com/developerworks/web/library/x-xforms/?loc=dwmain
Bernd
|
|
|
|
|
Hi Bernd
Thanks for this but the problem here is that XForms is not yet a standard and I need to get something implemented fairly soon.
|
|
|
|
|
Hello? Does anyone actually read this forum?
J
May the bear never have cause to eat you.
|
|
|
|
|
sure... why not?
"No matter where you go, there your are..." - Buckaoo Banzi
<pete>
|
|
|
|