Go Premium for a chance to win a PS4. Enter to Win

x

XML

20K

Solutions

13K

Contributors

Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).

Share tech news, updates, or what's on your mind.

Sign up to Post

I need to split an xml file which has multiple roots into files having one root. How can I achieve this?
0
New feature and membership benefit!
LVL 11
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

consider following XML -->

<?xml version="1.0" encoding="UTF-8"?>
<abc:Root
    xmlns:abc = "http://www.abc.com"
    xmlns:xyz = "http://www.xyz.com
    xmlns:xlink = "http://www.somelink.com"
    xmlns:xsi = "http://www.somelink.com/schema">

I have a class for the purpose of serialization/deserialization

[XmlRoot(Namespace="http://www.abc.com")]
public partial class Root{

}

How do i deserialize the above XML, so that I don't loose any of the additional namespaces?
with what I have, I ran a test

1. I deserialized the above XML , to create an object.
2. then i serialized the object in step 1, and looked at the XML.
3. The XMl generated is missing other namespace attribute in the root element . It only has the xmlns:abc attribute.

How do I make sure, i don't loose other namespace attribute when I deserialize?
0
I have an API consisting of two files that takes a url from a user, processed it, and sends an array to another file to return XML data back to the user. My problem is that I do not know how to get the return data (if I were the user) and parse it. Using a browser, the XML will display fine. I am hoping there are PHP functions that will send the url and retrieve the result for parsing.
Here is an example of the url sent by the user:
http://www.domain.com/xmlapi.php?a=1&b=2&c=3

Open in new window

Those query vars are then processed, sent to another server, and an array of results is returned. I then create a query string from those results place that string into another query and send that to another file that returns the XML.
The query string looks like this:
XMLProcess.php?Q=Element1^Value|Element2^Value|ElementThree^Value ... etc.

Open in new window

That file looks like this
   $dom = new DOMDocument("1.0", 'utf-8');
   header ("Content-Type:text/xml");
   $QArray = explode('|',$_REQUEST[Q]);
   foreach($QArray as $value)
   {
      $x = explode('^',$value);
      $XMLItems[$x[0]] = $x[1];
   }
   $root = $dom->createElement("Requests");
   $dom->appendChild($root);
   foreach($XMLItems as $key => $value)
   {
         $key = $dom->createElement($key);
         $root->appendChild($key);
         $variable = $dom->createTextNode($value);
         $key->appendChild($variable);
      }
   }
   echo $dom->saveXML();

Open in new window

As I say, this will display well-formatted xml in a browser, but is there a way to receive and parse this xml data with PHP?
Am I creating extra problems by having a secondary processing file (XMLProcess.php), rather than just including this XML creation code in the xmlapi.php file?

I'm trying to avoid using something like CURL or SOAP, if possible.
0
assume i have xml like

<People>
<Person>
 <First>John</First>
<Last>Smiths</Last>
</Person>
</People>

Open in new window


And i have xyz.pdf and have field name="First" and field name="Last"
In c#, I know I can use itextsharp to fill up the pdf. But I do not want how to read and map the fields.
My goal is to extract <element>Value</element>, and map the field name in pdf, and send email to someone

Thanks
0
Trying to create an SSRS report that uses ArcGIS web service to convert coordinates to feet. No matter what I do I only get the method envelope and not the return data which is an array of geometry (x,y).
Attached is the wsdl file.
The report and the dataset have the parameters mentioned in the dataset.
This is my datasource:
http://myserver:myport#/arcgis/rest/services/Utilities/Geometry/GeometryServer
This is my dataset:
<Query>
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.esri.com/schemas/ArcGIS/10.3">
<Method Name="Project" Namespace="http://www.esri.com/schemas/ArcGIS/10.3/">
           <Parameters>
                <Parameter Name="inSR" Type="String"></Parameter>
      <Parameter Name="outSR" Type="String"></Parameter>
      <Parameter Name="geometries" Type="Array"></Parameter>
      <Parameter Name="transformation" Type="String"></Parameter>
      <Parameter Name="transformforward" Type="String"></Parameter>
      </Parameters>
   </Method>
<SoapAction>=http://myserver:myport#/arcgis/rest/services/Utilities/Geometry/GeometryServer/project</SoapAction>
<ElementPath IgnoreNamespaces="True">ProjectResponse{}/Result{}/diffgram{}/Table{}/geometries{x,y}</ElementPath>
</definitions>
</Query>


I get the titlecell, breadcrumbs and apiref instead of getting the geometries x and y values.
GeometryServerwsdl.txt
0
I was able to retrieve the attached file thru a soap call to a web service, now i need to convert this xml file to a .csv file, is there an easy method of walking thru the xml file to extrtact the fields i need?
Tempxml3.xml
0
I have been trying to pass a string to fetch the node and am successful for string with only single quote (') and only double quotes ("). But am unable to parse it when string contains both singe and double quotes. I have my string in CString as-

CString str=L("H'el"lo");
and all other combinations of these. Can you please tell me how to do in C++, i have seen the examples are in C# but that are not helping me out.

Here's the link for C# Encoding XPath Expressions with both single and double quotes

XmlNode n = doc.SelectSingleNode(“/root/emp[lname=" + str + "]“);
How should i make my str work for string containing both single and double quotes in any order.
0
hi,

while executing below xquery

for $x in doc("Books.xml")/books/book
return if{$x/@category="XML")then<XMLBOOK>{data($x/title)}</XMLBOOK>
else <NONXML>{data($x/title)}</NONXML>


on below xml


<?xml version="1.0" encoding="UTF-8"?>
<books>
	<book category="JAVA">
		<title>Master Core Java</title>
		<author>JG</author>
		<year>2015</year>
		<price>50</price>
	</book>

	<book category="DOTNET">
		<title>Get Certified in .Net</title>
		<author>BG</author>
		<year>2016</year>
		<price>60</price>
	</book>

	<book category="XML">
		<title lang="en">XML and XML Schema Definition in easy steps</title>
		<author>BT</author>
		<year>2014</year>
		<price>20</price>
	</book>

	<book category="XML">
		<title lang="en">XSLT XPATH and XQuery Fundamentals</title>
		<author>BT</author>
		<year>2016</year>
		<price>30</price>
	</book>
</books>

Open in new window

getting below error

Syntax error on line 2 at column 9 of file:/C:/Users/sg/gpJava/ud/xsl_xpath_jquery/XQuery/Books2.xqy near {....xml")/books/book return if...}
  XPST0003: Unrecognized node constructor if{}
Static error(s) in query

how to fix it
please advise
0
We have xml file that actually just look like HTML with input and select HTML for example, we have list of car maker, model and etc

We were able to parse xml on mvc project and it looks fine.

Now, we are trying to build admin portal to allow our manager to crud plus clone e.g. Car and model. But we have very short development time frame. I hope I can have some good ideas to start with or if you know any out of box solution and it will work as well
0
when we use multiple xsl templates and apply them

<xsl:template match="/">
            <html>
                  <body>
                        <h1>order info:</h1>
                        <xsl:apply-templates></xsl:apply-templates>

what are the practical use cases and sample examples on using multiple xsl templates say converting one xml to other xml format or from xml to html

please advise
0
Industry Leaders: We Want Your Opinion!
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I have several  Maintenance Plans that I am moving from one server to another 69 to be exact, I need to change the server connection string on the DTX package. I  know I can do it by opening each package as it is XML and do a find and replace but that is very tedious. I have tried the following code but it doesn't change the connection string.
use msdb
 
DECLARE @oldservername as varchar(max)
SET @oldservername='AMCHARAPP1\DYNAMICSGP'
 
-- set the new server name to the current server name
 
declare @newservername as varchar(max)
set @newservername= 'AMCHARAPP2'
 
declare @xml as varchar(max)
declare @packagedata as varbinary(max)
-- get all the plans that have the old server name in their connection string
DECLARE PlansToFix Cursor
FOR
SELECT    id
FROM         sysssispackages
WHERE     (CAST(CAST(packagedata AS varbinary(MAX)) AS varchar(MAX)) LIKE '%server=''' + @oldservername + '%')
 
OPEN PlansToFix
 
 
declare @planid uniqueidentifier
fetch next from PlansToFix into @planid
 
while (@@fetch_status<>-1)  -- for each plan
 
begin
if (@@fetch_status<>-2)
begin
select @xml=cast(cast(packagedata as varbinary(max)) as varchar(max)) from sysssispackages where id= @planid  -- get the plan's xml converted to an xml string
 
declare @planname varchar(max)
select @planname=[name] from  sysssispackages where id= @planid  -- get the plan name
print 'Changing ' + @planname + ' server from ' + @oldservername + ' to ' + @newservername  -- print out what change is happening
 
set

Open in new window

0
Hi,

I need to add cdata to a node in an xml while parsing xml. I was unable to parse the content from that node. i had added CDATA by editing the xml, it worked fine and able to parse. But i need to add CDATA on the fly while parsing the xml and need to read that value as string.

Please find the xml node that needs to be added with cdata in the attached xml.

<Descriptionlongue>
<p><strong>Froid Ventilé Multi Air Flow</strong><br/><strong>Classe Energétique A+</strong><br/><strong>Affichage LED</strong><br/><br/></p> <table class="fridge-mini-spec" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td>Volume total net <span>(L)</span></td> <td>432</td> </tr><tr><td>Volume utile du réfrigérateur <span>(L)</span></td> <td>290 </td> </tr><tr><td>Volume utile du congélateur <span>(L)</span></td> <td>142</td> </tr><tr><td>Classe énergétique</td> <td>A+</td> </tr><tr><td>Largeur * Profondeur * Hauteur (cm)</td> <td>79*70*181</td> </tr><tr><td>Finition</td> <td>Métal brillant</td> </tr></tbody></table>
</Descriptionlongue>
RQ562N4AC1-fr-1-.xml
0
I have a magento website in which I need to change the footer. I see the address change on the actual design area of the settings and I change it but it does not change the footer address. Do I need to get into the actual files to change it or am I missing the area in which I change that information?
0
Hello,
an xml file contains user records like:

<user>
<account_type>EXTERNAL</account_type>
<primary_id>BRMNTN62M16A944E</primary_id>
<first_name>John</first_name>
<last_name>Doe</last_name>

...other fields...

<user_identifier>
<id_type desc="Additional">02</id_type>
<value>john.doe@mymail.com</value>
</user_identifier>

...other fields...

</user>

Open in new window

it happens that some records have the SAME <primary_id> but the <value> of the <user_identifier> of <type> 02 (see above) have a value different than "<first_name>.<last_name>@mymail.com"
is it possible individuating & suppressing all and only these <user> records?
Thanks a lot,
Fabiano
0
Hi,

I'm trying to capture the text between the <soap:Header>.....</soap:Header> tags in one web service request and replace it into another request. I can capture the whole xml ok but having issues with the regex to extract out the content between the header tags. The error I'm getting is below

java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 37 (?= .*?(?= ) ^ error at line: 9

The regex I'm using is below but it is error as above

strRequest2 = strRequest2.replaceAll("(?<=<soap:Header>.*?(?=</soap:Header>)","Insert New Header");

The content between the header tags I'm capturing is quite long with a mix of characters and other elements

Any assistance in how to use regex capture the content between the two header tags and then regex to replace the content between another two header tags would be very appreciated

Thanks

Gavin
0
In jquery, is it possible to find element then get the rest of the nodes(outside of original element)?
E.g.

If i pass you BondName = abc and if it is found, then output me everything within <additionalInformation>?

 <Surety>
  <SuretyLine>
   
    <Commercial>
      <Bond>
		<General Information>
		<BondName>abc</BondName>
   		</General Information>
		<AddtionalInformation>
          		<div class="col-lg-12">
           		 <Input Type="text" Name="additionalInfo_licenseNo" ID="additionalInfo_licenseNo" Onchange="fnSaveSingleData(this.name,'1')" Placeholder="Enter License No." 				Class="form-control" Title="License is required!" PrefillValue="No" Required="" />
          		</div>

        	</AddtionalInformation>
      </Bond>
       <Bond>
	<General Information>
		<BondName>xyz</BondName>
   	</General Information>
	<AddtionalInformation>
          <div class="col-lg-12">
            <Input Type="text" Name="additionalInfo_licenseNo" ID="additionalInfo_licenseNo" Onchange="fnSaveSingleData(this.name,'1')" Placeholder="Enter License No." Class="form-control" 		Title="License is required!" PrefillValue="No" Required="" />
          </div>
        </AddtionalInformation>
      </Bond>
    </Commercial>
  </SuretyLine>
</Surety>

Open in new window

0
Hi Experts,

We have been working on a script which scans through  xml files and pulls out information like database name, databaseServername etc from multiple xml files.

I am attaching sample xmls which are used by script to scan.

The script is as follows:
nohup timeout 15 cat context.xml
        sleep 10
        cat nohup.out|grep -i "driverClassName="|grep -i oracle >/dev/null 2>&1
 if [ $? -eq 0 ]
  then
        OUr=`cat nohup.out|grep url=|awk -F= '{print $2}'`
        DS=`echo $OUr|awk -F: '{print $4}'|sed s/@//g`
        DB=`echo $OUr|awk -F: '{print $NF}'|sed s/\".*//g`
        DB1=`echo $DB|sed s/\".*//g`

else
        DS=`cat nohup.out |grep url=|grep jdbc|head -1|awk -F/ '{print $3}'|awk -F";" '{print $1}'|awk -F":" '{print $1}'`
        DB=`cat nohup.out |grep url=|grep jdbc|head -1|awk -F";" '{print $2}'|awk -F= '{print $2}'|sed s/\".*//g`
        Ru=`cat nohup.out|grep "Environment name"|grep PegaRULES|awk '{print $3}'|awk -F= '{print $2}'|sed s/\"//g`
   if [ -z "$Ru" ]
    then
        Ru=`cat nohup.out|grep username=|awk -F= '{print $2}'|sed s/\"//g`
   fi
 fi

Open in new window


This works for 90 percent of cases which have only one Resource Name (example: context_works.xml and context_works2.xml)

But, in 10 percent of xmls when there are multiple resources (like context_doesnotwork.xml), it doesnt picks the right one, due to the oracle grep check, but I would like to be able to pick the resource which has the name=jdbc/PegaRULES.(It picks Oracle instead of picking the resource with name jdbc/PegaRULES). I would like to eliminate resources other than the ones with name=jdbc/PegaRULES before the grep for Oracle in the file.
Is there a way by which I can do that without losing much of the current logic?
context_works.xml
context_works2.xml
context_doesnotwork.xml
0
Hi All,

Quick question, I just exported the old configuration if DirSync server as xml file. now im going to import it in Azure AD connect migrate.exe.

but now the question is i have 3 xml file exported from old Dirsync, which 1 i need to import.
0
Hi, I'm trying to extract the header from a previous request in SoapUI so I can use it in another request. Basically, I want to get the node value for Header in one  xml and insert it into the header value of another xml. I have tried using XMLSlurper and XMLParser but not getting exactlty what I want. I can extract out the text from the nodes but need the actual whole header value so it can be inserted into other requests as needed. Looking at the XML Request example below I want to extract out

 
<soapenv:Header>
   	<soapenv:MyTag>old</soapenv:MyTag>
   	<soapenv:MyTag2>old</soapenv:MyTag2>
   </soapenv:Header>

Open in new window


Full example would be something like below

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header>
   	<soapenv:MyTag>old</soapenv:MyTag>
   	<soapenv:MyTag2>old</soapenv:MyTag2>
   </soapenv:Header>
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>AFA</web:FromCurrency>
         <web:ToCurrency>ALL</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>

Open in new window


Once I have the value I will need to insert it into the header as an xml sample such as below

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>   	
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>AFA</web:FromCurrency>
         <web:ToCurrency>ALL</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>

Open in new window


Hope this makes sense and any suggestions on how to get the node value for Header in xml and insert it into the header value of another xml would be very appreciated

Thanks
0
Concerto's Cloud Advisory Services
LVL 5
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

I am trying to convert a SQL Server stored procedure to Post gres procedure but stuck up in the XML portion.  Need help in converting this XML piece of code to post gres code.

EXEC sp_xml_preparedocument @idoc OUTPUT, @ROLES;
                  UPDATE SSO_XREF_USER_ROLE SET ACTV_IND=1 WHERE
                  (CONVERT(VARCHAR,SSO_USER_ID)+CONVERT(VARCHAR,SSO_ROLE_ID)) IN
                  (SELECT CONVERT(VARCHAR,X.SSO_USER_ID)+CONVERT(VARCHAR,X.SSO_ROLE_ID) FROM
                        (SELECT XUR.SSO_USER_ID,SR.SSO_ROLE_ID FROM SSO_XREF_USER_ROLE XUR
                              JOIN SSO_ROLE SR ON XUR.SSO_ROLE_ID=SR.SSO_ROLE_ID WHERE
                              SR.SSO_ROLE_NM IN
                              (SELECT RoleName FROM
                                    OPENXML(@idoc, '/DocumentElement/UpdateRoles', 2)
                                          WITH (RoleName  varchar(100),
                                                      RoleStatus  numeric(1,0))
                                                      WHERE RoleStatus=1))AS X)

Not sure what is the equivalent of sp_xml_preparedocument in Postgres procedure
0
Hi,
  how to write stored procedure to pass xml as input parameter in sql server 2012 explain with simple example .
0
I want to do something like in jquery

if the state = "CA" and bondname = "Contractor1" then
      show me the status element value e.g. "Online"

how can I do that in Jquery?

<Surety>
  <SuretyLine>
    <Commercial>
      <Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">Contractor 1</Name>
          <State ID="bondState" PrefillValue="Yes">CA</State>
       </GeneralInformation>
         <Image></Image>
        <Status>Online</Status>
      </Bond>
  <Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">Contractor 2</Name>
          <State ID="bondState" PrefillValue="Yes">CA</State>
       </GeneralInformation>
         <Image></Image>
        <Status>Online</Status>
      </Bond>
            <Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">Contractor asdfasd</Name>
          <State ID="bondState" PrefillValue="Yes">FL</State>
       </GeneralInformation>
         <Image></Image>
        <Status>Online</Status>
      </Bond>
</Commercial>
</SuretyLine>
</Surety>

Open in new window

0
When the fnGetBondNameList is called, the selected <option> is always dropped into the last one of the dropdown list.
How can I make it just select the first option in the dropdown?


function fnGetBondNameList(bondState) {
            $.ajax({
                url: "http://localhost:5489/BondList.xml",
                success: function (xml) {
                    parseSelectXML(xml,"bondName","Bond",bondState);
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert("Status: " + xhr.status);
                    alert("Error: " + thrownError);
                }
            });
    }
function parseSelectXML(xml, selectid, xmlnode, bondState) {
    var selecthtml = "", selectBondName="";
    var i = 0;
    $(xml).find(xmlnode).each(function () {
                if (bondState == $(this).find('GeneralInformation').find('State').text()) {
                    selectBondName = $(this).find('GeneralInformation').find('Name').text();
                    selecthtml += '<option value="' + selectBondName + '">' + selectBondName + "(" + bondState + ") "  + '</option>';
                    i = i + 1;
                  //  alert(selecthtml);
                }
    });
             $("#" + selectid).prop("disabled", false);
             $('#' + selectid).html(selecthtml).val(selectBondName);
             //modal information
             $('#' + "bondListFilterByState").html(selecthtml).val(selectBondName);
             $('#' + 

Open in new window

0
In VBA PPT custom ribbon tab throws this error, "The macro cannot be found or has been disabled because of your Macro security settings" while running some macros . But it doesnt appear while running from the code. Please help solve it. The attach file contains all the macros and ribbonx code. Set Text Margins (Module1.frmIntMargin_show1) is an example of the error
0
Is there anyone here, who can help me how to integrate Sadad payment method with Alinma bank
0

XML

20K

Solutions

13K

Contributors

Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).