English 中文(简体)
从xml中提取案文,并将xml数据转换成对应法
原标题:extract out text from xml and return converted xml data as response in asp classic

我正试图在伙伴关系的典型和“将数据转换成新的XML”中,要求从电子商务信息预报中获取xml数据,并将这些数据作为回应。

这是协会的文字。

<%

product_code = Request.QueryString("product_code")
url = "http://www.the site.com/net/WebService.aspx?Login=name@thehost.com&EncryptedPassword=***********&EDI_Name=GenericProducts&SELECT_Columns=p.ProductCode,p.ProductName,pd.ProductDescriptionShort,pe.ListPrice,pe.ProductPrice,pe.SalePrice&WHERE_Column=p.ProductCode&WHERE_Value=" & product_code
Set xData = CreateObject("Microsoft.XMLHTTP")
xData.Open "get", url, False
xData.Send 
Response.ContentType = "text/xml"
Response.write (xData.responseText)
Set xData = Nothing

%>

这里是一份称为“APIC”的书本中回归数据的样本。 例如,如果上述网页被称作数据,我用www.thesite.com/getdata.asp?product_code=m406789。 之后将归还下列人员。

<?xml version="1.0" encoding="UTF-8"?>
<xmldata>
   <Products>
       <ProductCode>M406789</ProductCode>
       <ProductID>858</ProductID>
       <ProductName>M406789 Ignition Box</ProductName>
       <ProductDescriptionShort>&lt;img alt="" src="/v/vspfiles/assets/images/alliance_small.jpg" align="right" /&gt;Ignition Box</ProductDescriptionShort>
       <ListPrice>134.2200</ListPrice>
       <ProductPrice>80.5300</ProductPrice>
       <SalePrice>59.9500</SalePrice>
   </Products>
</xmldata>

我想做的是,回归的XML数据就是如此。

<?xml version="1.0" encoding="UTF-8"?>
<hotspot>
    <ProductCode>M406789</ProductCode>
    <ProductID>858</ProductID>
    <ProductName>M406789 Ignition Box</ProductName>
    <ProductDescriptionShort>&lt;img alt="" src="/v/vspfiles/assets/images/alliance_small.jpg" align="right" /&gt;Ignition Box</ProductDescriptionShort>
    <ListPrice>134.2200</ListPrice>
    <ProductPrice>80.5300</ProductPrice>
    <SalePrice>59.9500</SalePrice>
</hotspot>

任何帮助或抽样守则都会受到高度赞赏。 不知道要走什么路。

最佳回答

Could be like this:

<%
product_code = Request.QueryString("product_code")
url = "http://www.the site.com/net/WebService.aspx?Login=name@thehost.com&EncryptedPassword=***********&EDI_Name=GenericProducts&SELECT_Columns=p.ProductCode,p.ProductName,pd.ProductDescriptionShort,pe.ListPrice,pe.ProductPrice,pe.SalePrice&WHERE_Column=p.ProductCode&WHERE_Value=" & product_code
Set xData = Server.CreateObject("MSXML2.ServerXMLHTTP")
    xData.Open "GET", url, False
    xData.Send
Dim xNewDoc
Set xNewDoc = xData.responseXML  ResponseXml returns DOMDocument object
    With xNewDoc
        .RemoveChild .FirstChild
        .InsertBefore .createProcessingInstruction("xml","version= 1.0  encoding= ISO-8859-1 "), .FirstChild
        Set hotspot = .CreateElement("hotspot")
        For Each e In .SelectSingleNode("//Products").ChildNodes
            hotspot.AppendChild e
        Next
        Set .DocumentElement = hotspot
        Response.ContentType = "text/xml"
        Response.Write .Xml
    End With
Set xNewDoc = Nothing
Set xData = Nothing
%>
问题回答

Kul has the answer (well just the code that probably will work) but a lot has been left unsaid that should be said.

首先是:

 url = "http://www.the site.com/net/WebService.aspx?Login=name@thehost.com&EncryptedPassword=***********&EDI_Name=GenericProducts&SELECT_Columns=p.ProductCode,p.ProductName,pd.ProductDescriptionShort,pe.ListPrice,pe.ProductPrice,pe.SalePrice&WHERE_Column=p.ProductCode&WHERE_Value=" & product_code

Drag the above scroll bar thumb to right to inform the security Manager hamare. 载于《URL》的一部明确的法典! 在我看来,似乎有可能用APIC来注入新的飞跃,我的猜测是,这些争.背后是一种简单的争辩。 如果是的话,应当立即从网站上撤回该《计划》。

在我胸部旁听。 利用服务器XMLHTTP与另一个服务器交谈,XMLHTTP并不安全,不应在ASP代码中使用。

为什么ISO-8859-1? 在UTF-8上任。





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签