In my VB script I generate an XML object which has XML of the form (see
below).
It has to be like this as I get the XML from an API

What I need to next in my ASP page is parse the XML in name value pairs
- however I need to sort on the 1st value

e.g I need something like this

5 65-MOV-317
5 65-MOV-318
5 65-MOV-319
5 65-MOV-330
5 66-MOV-317


3 65-MOV-001
3 65-MOV-002
3 65-MOV-003
3 65-MOV-331
3 66-MOV-315

etc.....

I haven't a clue how to achieve this, please any help would be
greatfulyl recieved


<Report>
- <Row>
- <Column>
<Value>1</Value>
</Column>
- <Column>
<Value>65-MOV-317</Value>
</Column>
</Row>
- <Row>
- <Column>
<Value>5</Value>
</Column>
- <Column>
<Value>65-PV-636</Value>
</Column>
</Row>
- <Row>
- <Column>
<Value>5</Value>
</Column>
- <Column>
<Value>65-RV-113</Value>
</Column>
</Row>
- <Row>
</Report>

Re: XML Help by Anthony

Anthony
Thu Aug 10 07:05:12 CDT 2006


<lltaylor2000@yahoo.com> wrote in message
news:1155207242.716078.101000@75g2000cwc.googlegroups.com...
> In my VB script I generate an XML object which has XML of the form (see
> below).
> It has to be like this as I get the XML from an API
>
> What I need to next in my ASP page is parse the XML in name value pairs
> - however I need to sort on the 1st value
>
> e.g I need something like this
>
> 5 65-MOV-317
> 5 65-MOV-318
> 5 65-MOV-319
> 5 65-MOV-330
> 5 66-MOV-317
>
>
> 3 65-MOV-001
> 3 65-MOV-002
> 3 65-MOV-003
> 3 65-MOV-331
> 3 66-MOV-315
>
> etc.....
>
> I haven't a clue how to achieve this, please any help would be
> greatfulyl recieved
>
>
> <Report>
> - <Row>
> - <Column>
> <Value>1</Value>
> </Column>
> - <Column>
> <Value>65-MOV-317</Value>
> </Column>
> </Row>
> - <Row>
> - <Column>
> <Value>5</Value>
> </Column>
> - <Column>
> <Value>65-PV-636</Value>
> </Column>
> </Row>
> - <Row>
> - <Column>
> <Value>5</Value>
> </Column>
> - <Column>
> <Value>65-RV-113</Value>
> </Column>
> </Row>
> - <Row>
> </Report>

It would have been helpful if you specified what you want to do with this
data?
In ASP you probably have 2 very different targets.
1) generate HTML to display in browser in which case using XSL would be the
solution.
2) stroe in a DB. If SQL Server the OPENXML is the answer if not then XSL
to a simpyfied XML OR a set to a set of SQL Inserts

Can you give us a better idea of where you are going?

This XSL can be used to simplfy the input XML:-

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />

<xsl:template match="/Report">
<report>
<xsl:for-each select="Row">
<xsl:sort select="Column[1]/Value" order="descending" />
<row groupNum="{Column[1]/Value}" code="{Column[2]/Value}" />
</xsl:for-each>
</report>
</xsl:template>

</xsl:stylesheet>

In ASP this can be used as:-

Dim oXSL : Set oXSL = Server.CreateObject("MSXML2.DOMDocument.3.0")
oXSL.async = False
oXSL.load "C:\MyStuff\simple.xsl"

Dim oXMLOut : Set oXSL = Server.CreateObject("MSXML2.DOMDocument.3.0")

oXMLIn.transformNodeToObject oXSL, oXMLOut


The oXMLOut DOM will hold XML in this form:-

<?xml version="1.0" encoding="UTF-16"?>
<report>
<row groupNum="5" code="65-RV-113" />
<row groupNum="5" code="65-PV-636" />
<row groupNum="1" code="65-MOV-317" />
</report>

It is sorted and easier to retrieve values:-

Dim oRow

For Each oRow in oXMLOut.documentElement.selectNodes("row")
' Do something with: oRow.getAttribute("groupNum")
' Do something with: oRow.getAttribute("code")
Next




Re: XML Help by lltaylor2000

lltaylor2000
Thu Aug 10 07:13:28 CDT 2006

Apologies, I shall elaborate a little more.

I query an API and it gives me a load of XML like I have pasted.

I then need to present this XML data in an ASP page in Tabular format
(i.e. I am producing a report).
Additonal to this I need to group the output of my report by the first
value node, which can be either 1,3,5

Does that make sense?

Many Thanks


Anthony Jones wrote:
> <lltaylor2000@yahoo.com> wrote in message
> news:1155207242.716078.101000@75g2000cwc.googlegroups.com...
> > In my VB script I generate an XML object which has XML of the form (see
> > below).
> > It has to be like this as I get the XML from an API
> >
> > What I need to next in my ASP page is parse the XML in name value pairs
> > - however I need to sort on the 1st value
> >
> > e.g I need something like this
> >
> > 5 65-MOV-317
> > 5 65-MOV-318
> > 5 65-MOV-319
> > 5 65-MOV-330
> > 5 66-MOV-317
> >
> >
> > 3 65-MOV-001
> > 3 65-MOV-002
> > 3 65-MOV-003
> > 3 65-MOV-331
> > 3 66-MOV-315
> >
> > etc.....
> >
> > I haven't a clue how to achieve this, please any help would be
> > greatfulyl recieved
> >
> >
> > <Report>
> > - <Row>
> > - <Column>
> > <Value>1</Value>
> > </Column>
> > - <Column>
> > <Value>65-MOV-317</Value>
> > </Column>
> > </Row>
> > - <Row>
> > - <Column>
> > <Value>5</Value>
> > </Column>
> > - <Column>
> > <Value>65-PV-636</Value>
> > </Column>
> > </Row>
> > - <Row>
> > - <Column>
> > <Value>5</Value>
> > </Column>
> > - <Column>
> > <Value>65-RV-113</Value>
> > </Column>
> > </Row>
> > - <Row>
> > </Report>
>
> It would have been helpful if you specified what you want to do with this
> data?
> In ASP you probably have 2 very different targets.
> 1) generate HTML to display in browser in which case using XSL would be the
> solution.
> 2) stroe in a DB. If SQL Server the OPENXML is the answer if not then XSL
> to a simpyfied XML OR a set to a set of SQL Inserts
>
> Can you give us a better idea of where you are going?
>
> This XSL can be used to simplfy the input XML:-
>
> <?xml version="1.0" encoding="utf-8" ?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" indent="yes" />
>
> <xsl:template match="/Report">
> <report>
> <xsl:for-each select="Row">
> <xsl:sort select="Column[1]/Value" order="descending" />
> <row groupNum="{Column[1]/Value}" code="{Column[2]/Value}" />
> </xsl:for-each>
> </report>
> </xsl:template>
>
> </xsl:stylesheet>
>
> In ASP this can be used as:-
>
> Dim oXSL : Set oXSL = Server.CreateObject("MSXML2.DOMDocument.3.0")
> oXSL.async = False
> oXSL.load "C:\MyStuff\simple.xsl"
>
> Dim oXMLOut : Set oXSL = Server.CreateObject("MSXML2.DOMDocument.3.0")
>
> oXMLIn.transformNodeToObject oXSL, oXMLOut
>
>
> The oXMLOut DOM will hold XML in this form:-
>
> <?xml version="1.0" encoding="UTF-16"?>
> <report>
> <row groupNum="5" code="65-RV-113" />
> <row groupNum="5" code="65-PV-636" />
> <row groupNum="1" code="65-MOV-317" />
> </report>
>
> It is sorted and easier to retrieve values:-
>
> Dim oRow
>
> For Each oRow in oXMLOut.documentElement.selectNodes("row")
> ' Do something with: oRow.getAttribute("groupNum")
> ' Do something with: oRow.getAttribute("code")
> Next


Re: XML Help by Anthony

Anthony
Thu Aug 10 08:12:37 CDT 2006


<lltaylor2000@yahoo.com> wrote in message
news:1155212008.637105.99620@i42g2000cwa.googlegroups.com...
> Apologies, I shall elaborate a little more.
>
> I query an API and it gives me a load of XML like I have pasted.
>
> I then need to present this XML data in an ASP page in Tabular format
> (i.e. I am producing a report).
> Additonal to this I need to group the output of my report by the first
> value node, which can be either 1,3,5
>
> Does that make sense?
>
> Many Thanks
>

This XSL generates the a table sorted by the value of the first column:-

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />

<xsl:template match="/Report">
<table>
<thead>
<tr><th>Group Number</th><th>Code</th></tr>
</thead>
<tbody>
<xsl:for-each select="Row">
<xsl:sort select="Column[1]/Value" order="descending" />
<tr>
<td><xsl:value-of select="Column[1]/Value" /></td>
<td><xsl:value-of select="Column[2]/Value" /></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</xsl:template>

</xsl:stylesheet>

Use:-

Response.Write oXMLIn.transformNode(oXSL)

to output the result.


>
> Anthony Jones wrote:
> > <lltaylor2000@yahoo.com> wrote in message
> > news:1155207242.716078.101000@75g2000cwc.googlegroups.com...
> > > In my VB script I generate an XML object which has XML of the form
(see
> > > below).
> > > It has to be like this as I get the XML from an API
> > >
> > > What I need to next in my ASP page is parse the XML in name value
pairs
> > > - however I need to sort on the 1st value
> > >
> > > e.g I need something like this
> > >
> > > 5 65-MOV-317
> > > 5 65-MOV-318
> > > 5 65-MOV-319
> > > 5 65-MOV-330
> > > 5 66-MOV-317
> > >
> > >
> > > 3 65-MOV-001
> > > 3 65-MOV-002
> > > 3 65-MOV-003
> > > 3 65-MOV-331
> > > 3 66-MOV-315
> > >
> > > etc.....
> > >
> > > I haven't a clue how to achieve this, please any help would be
> > > greatfulyl recieved
> > >
> > >
> > > <Report>
> > > - <Row>
> > > - <Column>
> > > <Value>1</Value>
> > > </Column>
> > > - <Column>
> > > <Value>65-MOV-317</Value>
> > > </Column>
> > > </Row>
> > > - <Row>
> > > - <Column>
> > > <Value>5</Value>
> > > </Column>
> > > - <Column>
> > > <Value>65-PV-636</Value>
> > > </Column>
> > > </Row>
> > > - <Row>
> > > - <Column>
> > > <Value>5</Value>
> > > </Column>
> > > - <Column>
> > > <Value>65-RV-113</Value>
> > > </Column>
> > > </Row>
> > > - <Row>
> > > </Report>
> >
> > It would have been helpful if you specified what you want to do with
this
> > data?
> > In ASP you probably have 2 very different targets.
> > 1) generate HTML to display in browser in which case using XSL would be
the
> > solution.
> > 2) stroe in a DB. If SQL Server the OPENXML is the answer if not then
XSL
> > to a simpyfied XML OR a set to a set of SQL Inserts
> >
> > Can you give us a better idea of where you are going?
> >
> > This XSL can be used to simplfy the input XML:-
> >
> > <?xml version="1.0" encoding="utf-8" ?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > <xsl:output method="xml" indent="yes" />
> >
> > <xsl:template match="/Report">
> > <report>
> > <xsl:for-each select="Row">
> > <xsl:sort select="Column[1]/Value" order="descending" />
> > <row groupNum="{Column[1]/Value}" code="{Column[2]/Value}" />
> > </xsl:for-each>
> > </report>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > In ASP this can be used as:-
> >
> > Dim oXSL : Set oXSL = Server.CreateObject("MSXML2.DOMDocument.3.0")
> > oXSL.async = False
> > oXSL.load "C:\MyStuff\simple.xsl"
> >
> > Dim oXMLOut : Set oXSL = Server.CreateObject("MSXML2.DOMDocument.3.0")
> >
> > oXMLIn.transformNodeToObject oXSL, oXMLOut
> >
> >
> > The oXMLOut DOM will hold XML in this form:-
> >
> > <?xml version="1.0" encoding="UTF-16"?>
> > <report>
> > <row groupNum="5" code="65-RV-113" />
> > <row groupNum="5" code="65-PV-636" />
> > <row groupNum="1" code="65-MOV-317" />
> > </report>
> >
> > It is sorted and easier to retrieve values:-
> >
> > Dim oRow
> >
> > For Each oRow in oXMLOut.documentElement.selectNodes("row")
> > ' Do something with: oRow.getAttribute("groupNum")
> > ' Do something with: oRow.getAttribute("code")
> > Next
>